Populate catalog task opened_by to be the same user who opened the request_item

Anna Gausel
Giga Expert

We have custom workflow framework to simplify our workflows and as a result all of our catalog task default the opened_by to 'system'

I've written an after insert/update business rule, but it is not updating the opened_by:

var sctask = new GlideRecord('sc_task');
sctask.get(current.sc_task);
sctask.opened_by = current.request_item.opened_by;
sctask.update();

I've reversed the logic and got it working the other way around:

var sctask = new GlideRecord('sc_req_item');
sctask.get(current.request_item);
sctask.opened_by = current.opened_by; //populates the RITM opened_by to 'system'
sctask.update();

Any ideas why my first script does not update the opened_by?

1 ACCEPTED SOLUTION

Anna Gausel
Giga Expert

Got it working correctly on the sc_task table:

current.opened_by = current.request_item.opened_by

I had my business running on after insert/update instead of before.

View solution in original post

12 REPLIES 12

SatheeshKumar
Kilo Sage

your business rule is in which table ..?? sc_task or sc_req_item?

 

Hi Satheesh

On the 'sc_req_item' table.

The second one ran successfully on the 'sc_task' table.

ok then .. the issue is 

there is no field in sc_req_item table as sc_task

also you cant access current.request_item.opened_by in sc_req_item record.it should be current.opened_by

 

requested and task has one to many relationship.

 

each requested item can have multiple tasks.

 

 

 

 

 

 

Thanks I've changed the table for the business rule to run on back to 'sc_task'

var sctask = new GlideRecord('sc_task');
sctask.get(current.request_item);
sctask.opened_by = current.request_item.opened_by;
sctask.update()

But still not having any luck populating the opened_by