- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 02:37 AM
how to get the reference field value and set that value in single line text variable.
I have catalog item under that i have
Requested by--
On behalf of - here i have two choices -me,on behalf-if suppose end user will select on behalf option he will change the requested by details that time pick that value set in -"on behalf of person"
on behalf of person--
i have catalog client script for on change
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(window == null){
var behalf = g_form.getDisplayBox('substantiation_requested_by_ref');
var user = behalf;
g_form.setValue('substantiation_name_of_the_person_this_is_on_behalf_of_stxt',user)
}
else{
var behalf = g_form.getDisplayBox('substantiation_requested_by_ref').value;
var user = behalf;
g_form.setValue('substantiation_name_of_the_person_this_is_on_behalf_of_stxt',user);
}
//Type appropriate comment here, and begin script below
}
am not getting the value
if change the script below like only native ui is working ,portal is getting java script browser console error.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var behalf = g_form.getDisplayBox('substantiation_requested_by_ref').value;
var user = behalf;
g_form.setValue('substantiation_name_of_the_person_this_is_on_behalf_of_stxt',user);
//Type appropriate comment here, and begin script below
}
can you help any one
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 02:47 AM
Hi,
something like this
1) Ensure Isolate Script field is set to false for your client script
2) This field is not on form but from list you can make it false
Note: The solution requires this Isolate Script field as false considering the window object in script being used
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var behalf;
if(window != null){
behalf = g_form.getDisplayBox('substantiation_requested_by_ref').value;
}
else{
behalf = g_form.getDisplayValue('substantiation_requested_by_ref');
}
g_form.setValue('substantiation_name_of_the_person_this_is_on_behalf_of_stxt', behalf);
//Type appropriate comment here, and begin script below
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 02:44 AM
Hi,
there is different syntax to get display value in portal
I have created blog for that to get it in Native + Portal
Get Display value of reference variable Service Catalog
If my blog helps please mark it helpful and also bookmark it
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2022 02:47 AM
Hi,
something like this
1) Ensure Isolate Script field is set to false for your client script
2) This field is not on form but from list you can make it false
Note: The solution requires this Isolate Script field as false considering the window object in script being used
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var behalf;
if(window != null){
behalf = g_form.getDisplayBox('substantiation_requested_by_ref').value;
}
else{
behalf = g_form.getDisplayValue('substantiation_requested_by_ref');
}
g_form.setValue('substantiation_name_of_the_person_this_is_on_behalf_of_stxt', behalf);
//Type appropriate comment here, and begin script below
}
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader