- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2017 06:50 AM
Hi ,
i had created one table OUTAGE and created fields (fields present in incident table ) now my requirement is if i select any Reference Field(eg.incident table) in outage table then it should populate all the fields related to that record
for this i had done through GlideAjax in that for multiple fields i had defined obj, but i am unable to fetch the values
here is the script which i have tried
Script include:
var outage_utils = Class.create();
outage_utils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCaller: function() {
var result = "";
var rm = this.getParameter('sysparm_pnt');
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',rm);
gr.query();
if (gr.next()){
//if (gr.get(rm)){
var obj = {};
obj.u_short_description = gr.short_description;
obj.u_impact= gr.impact;
obj.u_urgency=gr.urgency;
var json = new JSON();
result = new JSON().encode(obj);
gs.log('answeris '+result,'LS');
return result;
}
// }
// else return "No user1 found.";
},
/*gr.addQuery('sys_id',rm);
gr.query();
if (gr.next()) {
result = gr.short_description;
}
gs.log('Inside SI>> '+result,'MJ');*/
type: 'outage_utils'
});
Client Script :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('outage_utils');
ga.addParam('sysparm_name', 'getCaller');
ga.addParam('sysparm_pnt', newValue);
ga.getXML(displayUser);
// ga.get(record.sys_id);
}
function displayUser(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
answer = JSON.parse(answer);
//alert('Answer is >> '+answer);
//g_form.setValue('u_short_description', answer);
g_form.setValue('u_short_description', answer.short_description);
g_form.setValue('u_impact',answer.impact);
g_form.setValue('u_urgency',answer.urgency);
// g_form.setValue('description',answer.name);
}
Could you please help me in this
Thanks in Advance
Regards,
Sasidhar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2017 09:09 AM
Did you try with earlier script i have provided?
if you want to continue with Json part, try to change the line of code
var obj = {};
obj.u_short_description = gr.getValue('short_description').toString();
obj.u_impact= gr.getValue('impact').toString();
obj.u_urgency=gr.getValue('urgency').toString();
change these line and try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2017 09:32 AM
Thanks Balaji ,
This works Fine , first one i have no luck ,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2017 09:36 AM
Which one did not working? you mean to say json part one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2017 09:46 AM
JSON part Script is working ,made changes i had included 2nd script (obj part) which you had given ,
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2017 09:48 AM
If i have answer your question, please make it as correct
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View
How To Mark Answers Correct From Community Inbox