Opened by on catalog item generated from run script showing as the last person to approve the original catalog item

othomas1
Kilo Guru

Hi everyone,

I have a catalog item (work from home request) that launches another catalog item (work from home hardware) within the workflow, everything looks ok except that the opened by on the new catalog item that is launched in the workflow is being set to the last person to approve in the original catalog item, i need it to be the person who opens the work from home request, how can i change this?

 

Launch work from home request:

var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//add your requested item to the cart by sys_id of the catalog item
var item = cart.addItem('e66cb93a4f236f00259db3318110c76e', 1);

//fill in the variables on the request item form
cart.setVariable(item,'requested_for', current.request.requested_for);
cart.setVariable('opened_by', current.request.opened_by);
cart.setVariable(item,'work_at_home_coordinator', current.request.opened_by);
cart.setVariable(item, 'requested_for_supervisor', current.request.requested_for.manager);
var rc = cart.placeOrder();
workflow.scratchpad.request_number = rc.sys_id; //so it can be referenced later

 

 

 

find_real_file.png

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hi,

Can you try just:

current.opened_by

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hello Allen,

That change still produces the same results, its setting the opened by of the new catalog item to the last person to approve in the previous one.

Ok, well, in a run script activity at the very beginning of this workflow do this:

workflow.scratchpad.opened_by = current.opened_by;

Then...later in your activity where you're creating the catalog through the API, use the scratchpad: workflow.scratchpad.opened_by

This way it stores who opened it at the very beginning of all this and you can use it later when you want to and it won't be manipulated later by who approves stuff , etc.

Please mark reply as Helpful/Correct. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

it still doesnt seem to be working.

 

find_real_file.png

find_real_file.png