- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 02:18 AM
Hello Team,
I have configured a variable named Contact Number for a record producer in Service Portal for creating a new Incident.
But unfortunately the Contact Number is not getting auto-populated when the form loads. And also when I change the Caller Name I need to remove the number which is populated and populate the Caller's Number in that field.
Can anyone let me know how to configure the same?
Thanks in Advance...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2022 12:03 AM
@SNOW
Was not able to login to community yesterday all day. Please find the solution below on how you can achieve your last bit of requirement as well:
Just write a catalog UI Policy on your Record Producer and clear out the value of your Contact Number field. Steps shown below:
No Script required:
Save the Form and scroll down to Catalog UI Actions and click on new and select the Contact Number field and then make sure to check the Clear value field as shown below:
This is working for me.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 04:06 AM
Hi,
Write client script onchange of caller name.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
g_form.clearValue('contact');
return;
}
var ga = new GlideAjax('getUserDetails');
ga.addParam('sysparm_name', 'getUserInformation');
ga.addParam('sysparm_user_id', g_form.getValue('caller_id'));
ga.getXML(parseUserResponse);
//alert("test");
function parseUserResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
// alert(answer);
g_form.setValue("contact",answer);
}
Script include
var getUserDetails = Class.create();
getUserDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInformation: function() {
var user_sys_id = this.getParameter('sysparm_user_id');
var user = new GlideRecord('sys_user');
user.get(user_sys_id);
if (user.next()) {
var mob=user.mobile_number;
return mob;
}
},
type: 'getUserDetails'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 09:54 AM
Hi @SNOW
You do not need to do much of scripting here to get this requirement done and can be done with OOB functionality which is mostly configurable:
1) In your Caller Variable, open the Variable record and add the below line of code in the default value of caller which will default it to current logged in User :
javascript:gs.getUserID();
Now to get the Phone Number of current logged in User, create a Script Include and use the script as below:
var getContact = Class.create();
getContact.prototype = {
initialize: function() {},
getDetails: function() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', gs.getUserID());
gr.query();
if (gr.next()) {
return gr.mobile_phone.toString();
}
},
type: 'getContact'
};
Screenshot of Script Include:
Now in Contact Number Variable add the below line of code in the Default value as shown below:
javascript:new getContact().getDetails()
The above things will take care of your On Load Functionality . Now for your On Change you do not need any scripting at all and with just few configurations you can do this as per steps mentioned below:
1) In your record producer form scroll down and Navigate to Related List named as "Catalog Data Look Uop Definitions" as shown below:
Click on NEW button and configure it as shown below and save the record once done.
Scroll down and click on New on the Related List named as "Catalog Matcher Variable Definition" as shown below and configure it as below:
And on the other Related List named as "Catalog Setter Variable Definition" as shown below and click on New and configure it as shown below:
Follow each step carefully and you will be dine with your requirement. It is working for me and have tested it in my PDI.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2022 11:06 AM
Hello Shloke,
Nice it worked for me really!!!
But I have one doubt here like if I clear the Caller Name from Caller ID field the mobile number is not getting removed.It is staying as it is and once I replace with another Caller Name it populates the mobile number associated with that new Caller Name.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2022 06:35 AM
Hello Shloke,
Can you please help me out as I am struggling on the last part only.Please help me out.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2022 08:34 AM
Hello Shloke,
I am still awaiting your response on my query addressed. Please provide me the final step resolution so that I can apply the fix in my configurations.
Thanks