Service Request Api

naveenreddy0871
Tera Contributor

Hi , 

Requirement: Sc request raised by using Scripted rest api script  and Variables also should be passed.

 

I am trying using to use out of the box — Buy Item(Service Catalog Api) Script in custom Scripted Rest resources but getting errors .

 

kindly help to create new custom api by using out of the box api script .

 

1 ACCEPTED SOLUTION

Hi @naveenreddy0871 ,

 

you can use script like below. You need to query the record sys id and then pass.

var mgr = new GlideRecord('sys_user');
mgr.addQuery('name', manager);
mgr.query();
if (mgr.next()) {
    var managerSysID = mgr.sys_id;
    cart.setVariable(item, "requested_for_manager", managerSysID); //here it is a reference field
}

 

 

Please accept the solution if it helped.

View solution in original post

5 REPLIES 5

Hi @naveenreddy0871 ,

 

you can use script like below. You need to query the record sys id and then pass.

var mgr = new GlideRecord('sys_user');
mgr.addQuery('name', manager);
mgr.query();
if (mgr.next()) {
    var managerSysID = mgr.sys_id;
    cart.setVariable(item, "requested_for_manager", managerSysID); //here it is a reference field
}

 

 

Please accept the solution if it helped.