user record producer as a directory
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 08:56 AM
I want to use a record producer to have the user select the users name and show the field i have on the producer name phone populate the phone number to use the record producer as a directory anyone used record producers in this way here is the code im using
var user = current.variables.first_name;
var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', user);
gr.query();
if(gr.next()){
current.setValue(producer.phone, gr.phone);
current.setAbortAction();
}
producer.portal_redirect = '/sp';
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 09:44 AM
Hi @ServNowDev ,
1)Why don't you use out of the box feature(Dependent value) on the Phone variable as below to set Phone number automatically
2)Use Onsubmit clien script to check if Phone varibale is empty, if is empty throw a warning message and abort
function onSubmit() {
//Type appropriate comment here, and begin script below
if (!g_form.getValue("phone varibale Name")) { //replace with your phone variable value
alert("Phone is empty")
return false;
}
}
Hope this helps!!!
Accept and hit Helpful if it helps.
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025