- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 04:23 AM
Hi All,
I am trying to retrieve the username and update the value in discovered source user in a transform map runscript using function. Its returning sys_id than its value. Below is the script I'm using,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 09:32 AM
the above syntax did not work too. I created a separate field mapping for discovered source user, it worked good with the same script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 04:30 AM
Hi @Rashmi Rao
you need to use the getDisplayValue() function. This function returns the display value (name) of a referenced field (sys_id) from a record.
Here are the steps to fix this:
1. Identify the field that is returning sys_id. This is usually a reference field.
2. In your script, instead of directly using the field, use the getDisplayValue() function.
For example, if your field is 'assignment_group', and you are getting sys_id, you should use:
var groupName = current.assignment_group.getDisplayValue();
3. Replace all instances of the field in your script with the variable you just created.
4. Test your script to ensure it's now returning the correct value.
Here is a sample code:
javascript
var gr = new GlideRecord('incident');
gr.get('incident_number', 'INC0010023');
var groupName = gr.assignment_group.getDisplayValue();
gs.info(groupName);
In this code:
- A new GlideRecord is created for the 'incident' table.
- The get() function is used to get a specific incident.
- The getDisplayValue() function is used to get the display value of the 'assignment_group' field.
- The value is then logged to the system log.
Remember, the getDisplayValue() function can only be used on fields that are references to other tables. If the field is not a reference field, this function will not work.
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2024 05:36 AM - edited 02-05-2024 05:40 AM
Hello @Rashmi Rao
target.u_discovered_source_user = sys_user.getDisplayValue('user_name');//add field name which you are trying to access.
Above line needs to be corrected.
If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers!
Thanks and Regards,
Abhijeet Pawar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 09:32 AM
the above syntax did not work too. I created a separate field mapping for discovered source user, it worked good with the same script.