How to fetch requested item variable via background scripts

Kaka Nayeem
Tera Guru

Hi All,

      I need to fetch requested item variable's value from requested item table via script.

      ritm.JPG

          From the above image, i need to access the value which i have marked.

Thanks & Regards,

Kaka Nayeem

1 ACCEPTED SOLUTION

amlanpal
Kilo Sage

Hi Kaka,



The script will be something like below. Variable's value from RITM can be fetched always by object.variables.variable_name.



var gr = new GlideRecord('sc_req_item');


gr.addQuery('number', 'RITM0000013');


gr.addQuery('gr.variables.color_you_like', 'black');


gr.query();


if(gr.next())


{


//do your logic


}



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

3 REPLIES 3

amlanpal
Kilo Sage

Hi Kaka,



The script will be something like below. Variable's value from RITM can be fetched always by object.variables.variable_name.



var gr = new GlideRecord('sc_req_item');


gr.addQuery('number', 'RITM0000013');


gr.addQuery('gr.variables.color_you_like', 'black');


gr.query();


if(gr.next())


{


//do your logic


}



I hope this helps.Please mark correct/helpful based on impact


Hi Amlan,


       


        Your code is working fine.



          Thanks for Help



Regards,,


Kaka Nayeem


hi 

 

am new to service now...please anyone tell me on which table do i have to add this code in business rule or what will be the logic in 

 

if(gr.next())

 

{

 

//do your logic // inside this

 

}

as i have the similar requirement where am able to generate those fields on sc task form but am not able to fetch those values from ritm form ...please help me with this

thanks in advance!!