This sample script is to populate the requester details in a request additional field.
Based on the requester name selected, we can fetch the user additional field informations using Field and Form Rules (FAFR) and populate the content in request additional field.
We have considered a user additional field named "Country" and this information has to be populated in our request additional field "Requester Country".
1. Create a new 'Single Line' additional field for the request to hold the user additional field information. Copy the "column name" of the additional field created.
2. Go to Admin > Incident Templates > Select a particular template > Field and Form Rules > Rule execution - On Create / Edit > Event - "On Field Change" - "Requester" > Actions - Execute Script - Copy Paste the attached content and save the script.
3. Modify the attached script to update the request and user additional field informations. Please follow the comments added in the script.
4. The request additional field will get updated when the requester field is modified, while creating a request.
How to find the UDF name of a field in the Request Form:
Note : Version below 11.0, use the script.txt and from version 11.0, use the script (script_11000)
With ESM (11000) release, requesters can be given access for GET and GET ALL users api operations to achieve certain requirements. This will be disabled by default and needs to be enabled by executing the below query in the database,
update globalconfig set paramvalue=true where parameter = 'AllowUserAPIInRequesterLogin';
Refer to this article for the instructions to connect to the database. Refer to this post for further information.