Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How can we get the requested item related to current request?

anjiadmin
Tera Expert

How can we get the requested item related to current request?

I able to to get the requested items along with the current request item.

But I want to display the requested item related to current request.

I am using the below code.

template.print("<p></p>Requested items:<br />");

var gr = new GlideRecord("sc_req_item");

gr.addQuery("request_item", current.sys_id);

gr.query();

while(gr.next()) {

template.print(gr.number + ":   " + gr.cat_item.getDisplayValue() + ", Stage: " + gr.stage.getDisplayValue() + "<br />");

}

Regards,

Y Anjaneyulu

18 REPLIES 18

Yes Priya. I want to show all the RITM's which are related to the current request.




Thanks,


Y Anjaneyulu


Did u get my point..



Thanks,


Y Anjaneyulu


Hi Anji,



Yes I got your points. When I try from background script I could get the records (RITM's) that are associated with the Request.



Thanks,


Priyanka R


anjiadmin
Tera Expert

var gr = new GlideRecord("sc_req_item");


gr.addQuery('sys_id',current.task);


gr.query();


if(gr.next( ) )


{


//gs.log("My email script"+gr.number);


template.print(gr.number + ":   " + gr.getDisplayValue('cat_item') + ", Stage: " + gr.stage + "<br />");


}



This is working !


Hi ,



Can you please tell me for which table you are witting the script?



Thanks,


Priyanka R