How to get the values of multiple fields from one table to another table by changing one field

sasidhar3
Kilo Contributor

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

1 ACCEPTED SOLUTION

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.


View solution in original post

8 REPLIES 8

Thanks Balaji ,



This works Fine , first one i have no luck ,


Which one did not working? you mean to say json part one.


JSON part Script is working ,made changes i had included 2nd script (obj part) which you had given ,



Thank you


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