By selecting the Opened for I want to Auto populate Contact number by using the Sciptinclude
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 11:03 PM
Hi,
i have used the below script with contact number modifications but it is not working as expected. hence contact number is not populating
please find the below mentioned Screenshots for the same.
Please help me out if i can do any modifications in the script.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 11:56 PM
I have tried it but nu luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 12:19 AM
If you are on Utah or later release you can use auto-populate feature
Did you explore that?
New in Utah! Auto-populate variable based on a reference
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 12:41 AM
Yes Ankur, i have used the same feature and it is working fine as well.
But if i login to the end user then Contact number is not populating.
(or)
If i impersonate then it is not working hence my boss is suggested to use the Scriptinclude.
Please help me on the same.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 01:03 AM
@kranthi2 , base on your code, it should work. Try below:
- Set the UI Type to 'All'
- Inside Script Include, add log message
gs.info('contact_no', contact_no); // add this line
return contact_no;
- Inside Client script, add an alert to see if you can get the value
if (contact_num) {
alert(contact_num); // add this line
g_form.setValue('u_pre_contact', contact_num);
}
- Make sure you have that value for selected user in user record.