I have a Incident form if i select Caller field in Incident form then all the Fields like mobile number, location, name, Email Should be auto populate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 04:10 AM
Hi,
I have a Incident form if i select Caller field in Incident form then all the Fields like mobile number, location, name, Email Should be auto populate.
Can any one help me out for the same.
Awaiting for your response,
Regards,
Sreenadh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 12:44 PM
Hey Kranthi,
g_form.getReference just ends up calling the client-side GlideRecord API. In my opinion, client-side GlideRecord should be avoided as much as possible, since it usually results in a lot of data being transferred needlessly. Its better if you use GlideAjax and script include.try below code,
Onchange client script
field: Caller
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue == ''){
g_form.setValue('caller_phone','');
g_form.setValue('caller_email_address','');
//Type appropriate comment here, and begin script below
}
else
{
var ga = new GlideAjax('ScriptIncludeName');//your script include name
ga.addParam('sysparm_name','populateUser');//your script include function name
ga.addParam('sysparm_user',newValue);
ga.getXML(UserInfo);
}
}
function UserInfo(response)
{
var answer2 = response.responseXML.documentElement.getAttribute('answer');
var ans3 = answer2.split(",");
//alert('Answer:'+ans3);
if(answer2 != ''){
g_form.setValue('caller_phone',ans3[0]);
g_form.setValue('caller_email_address',ans3[1]);
}
}
--------Script Include-----
Name: ScriptIncludeName
Client callable --> true
populateUser: function(){
var mbphone='';
var email='';
var phone='';
var user1 = this.getParameter('sysparm_user');
//gs.addInfoMessage('sys_id' + user1);
var gr1=new GlideRecord('sys_user');
gr1.addQuery('sys_id',user1);
gr1.query();
if(gr1.next())
{
phone = gr1.phone;
email = gr1.email;
//gs.addInfoMessage('returing' + mbphone + ',' + phone + ',' + email);
}
return phone + ',' + email;
},
Please Mark Correct and Helpful If you find my answer worthy.
Regards,
Indrajit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2020 12:50 PM
Here is an article that will help you:
Please mark my response as correct answer and helpful if it helped solved your question.
-Best Regards
Prateek kumar
Please mark my response as correct and helpful if it helped solved your question.
-Thanks