Create Incident Record producer while selecting contact phone details sometimes show wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 03:03 AM
Create Incident Record producer while selecting contact phone details sometimes show wrong data in fields. And date get populate to fields from the client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 03:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 10:14 AM
post full client script and script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 05:40 AM
Script Include:
var Details = Class.create();
Details.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDetails: function() {
var obj = {};
obj.mobile_phone = "";
obj.phone = "";
var requestedforSysID = this.getParameter('sysparm_openFor');
var grObj = new GlideRecord("sys_user");
grObj.addQuery("sys_id", requestedforSysID); //comparing sysID
grObj.query();
if (grObj.next()) { //getting user details
obj.mobile_phone=grObj.getValue("mobile_phone");
obj.phone = grObj.getValue("phone");
}
var data = JSON.stringify(obj);
return data;
},
type: 'Details'
});
Client Script :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var openFor = g_form.getValue('caller_id'); //gettin sysID of requestedFor
var abc = new GlideAjax('Details'); // script include name
abc.addParam('sysparm_name', 'getDetails'); //function name
abc.addParam('sysparm_openFor', openFor); //pushing requestedFor sysID into server side
abc.getXMLAnswer(callbackdata);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 06:55 AM
Hi @AshishD18291065
I have tried your Script logic and getting expected output .
var obj = {
mobile_phone: "",
phone: ""
};
var grObj = new GlideRecord("sys_user");
grObj.addQuery("sys_id", '292bebbd9749d1101f1b30200153af5f');// Replace with the desired sys_id
grObj.query();
if (grObj.next()) {
obj.mobile_phone = grObj.getValue("mobile_phone"); //Here you can use .toString() Method
obj.phone = grObj.getValue("phone"); //Here you can use .toString() Method
}
var data = JSON.stringify(obj);
gs.print("Data: " + data);
var push = JSON.parse(data);
gs.print("Mobile Phone: " + push.mobile_phone + '');
gs.print("Phone: " + push.phone + '');
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna