need help with scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I am trying to auto-populate names in my service catalog record producer. Pulling from the client table to the appt table that I created. I am not using the sn appt table. I have created a catalog UI policy when a change occurs, and Script include for the client calling and a Script for the catalog and created a new ACL. I am not the best at the scripting and leaned on SN chat gpt but it is not populating. Can someone help. Have I made this too restrictive?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @cj10121 , I thinks there is no need to use the script include this can also be done using catalog client script and record producer script using getReference() object in servicenow.
Catalog client script -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('client', function(ref) {
g_form.setValue('client_name', ref.u_name);
g_form.setValue('client_email', ref.u_email);
});
}
Producer script -
(function producerScript(producer) {
var gr = new GlideRecord('u_appt');
gr.initialize();
gr.u_client = producer.client; // reference field
gr.u_client_name = producer.client_name;
gr.u_client_email = producer.client_email;
gr.insert();
})(producer);
If this solution helped you Please Mark this solution as accepted and helpful as it will be helpful for other users and readers as well.
Best Regards.
Saurabh V.