- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2022 03:50 PM
Hi,
i have to put(get) the same value who exist in the fields (affecté a) in the fields (incident) in this example in the fields (Affecté a) i have "GUERRIER BASTIEN" i should have the same value in the fields "Incident"=> "GUERRIER BASTIEN" automatically is this possible
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 12:34 PM
Hi, a reference field would return a sys_id, and you will need to get the field display value for the field involved
You have a number of options
GlideAjax to return to query and return the records display value
getReference() to return the entire record and then populate the display value by dot.walking the field, this may have an impact on UI performance
getDisplayBox()
This post has examples of getReference() and getDisplayBox()
https://community.servicenow.com/community?id=community_question&sys_id=1c8a84e8db759b80032a7a9e0f96...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2022 04:17 PM
Hi, are both of these fields references to the same table?
If yes and if this is required in the UI you would use an onChange() against your source field, and simple map the source field to the target.
g_form.setValue('targetField', newValue);
If you don't need to see the value immediately in the UI, IE you can wait till the record is saved to populate the value then you can use a before BR
current.targetField = current.sourceField;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 01:24 AM
hi
apologize for the delay and thank you for your reply , i try it to create a client script onchange
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var name = g_form.getValue("assigned_to");
g_form.setValue("u_demandeur",name);
}
don't work coorectly in the field i got the sys id of the user not the name how can i fix that, i need to get the same name not the sys id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 12:34 PM
Hi, a reference field would return a sys_id, and you will need to get the field display value for the field involved
You have a number of options
GlideAjax to return to query and return the records display value
getReference() to return the entire record and then populate the display value by dot.walking the field, this may have an impact on UI performance
getDisplayBox()
This post has examples of getReference() and getDisplayBox()
https://community.servicenow.com/community?id=community_question&sys_id=1c8a84e8db759b80032a7a9e0f96...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 10:29 AM
If both the fields are reference Fields , Just Select Autopopulate in the Record by Dot Walking the Required Field you can see same value which is already assigned