
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 03:14 AM
Hi, I have a variable set which is used on about 100 record producers. I have added a field to the variable set which is populated with the contact phone number of the user. I also have a checkbox next to it. If selected, the phone number field is no longer read only and the user can update.
Onsubmit, if this field is checked, I want this to update the record on the sys_user table with the new phone number.
As the variable set is on 100 RP's, I dont want to go into every single RP to add to the script.
Is there a way I can do this with an OnSubmit catalog client script similar to how the map to field functionality works?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 09:00 AM
Hi @M_iA ,
Try the below script.
var checkboxResponse = g_form.getValue('update_my_profile');
if (checkboxResponse == 'true' || checkboxResponse == true) {
var ga = new GlideAjax('global.CustomerHelpCenterUtils');
ga.addParam('sysparm_name', 'setContactNumber');
ga.addParam('sysparm_number', g_form.getValue('contact_number'));
ga.addParam('sysparm_user', g_form.getValue('contact'));
ga.getXMLAnswer(myCallbackFunction);
function myCallbackFunction() {
return;
}
Mark helpful and accept the solution if it helps in Solving your query
Regards,
Johns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 04:30 AM
record producer is on which table?
did you debug your scripts?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 04:42 AM
record producer sits on the sn_customerservice_case table.
Yes, I have added the following to the script include, but nothing showing in the logs suggesting that its not even getting as far as the script include?
var CustomerHelpCenterUtils = Class.create();
CustomerHelpCenterUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
setContactNumber: function() {
var contact = this.getParameter('sysparm_number');
gs.log('MTA number: ' + contact);
var userid = this.getParameter('sysparm_user');
var user = new GlideRecord('sys_user');
if (user.get(userid))
{
user.phone = contact;
user.update();
}
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 05:07 AM
try using gs.info() for logs and check. Also check if it is entering client script
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 07:19 AM
if you are in scoped app then use gs.info() as gs.log() won't work
are both the scripts in same scope?
Is your script include client callable?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 08:22 AM
I have updated:
But it still isnt adding to the logs. Both scripts are in global scope.
I also, update the client script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var checkboxResponse = g_form.getValue('update_my_profile');
if (checkboxResponse == 'true' || checkboxResponse == true) {
var ga = new GlideAjax('global.CustomerHelpCenterUtils');
ga.addParam('sysparm_name', 'setContactNumber');
ga.addParam('sysparm_number', g_form.getValue('contact_number'));
ga.addParam('sysparm_user', g_form.getValue('contact'));
alert('I got here');
}
}
And alert popup does trigger