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

Soumita3
Tera Expert

Hi Anna,

 

The line "sctask.get(current.sc_task);" returns a "NULL" value hence your BR is not being processed.

Could you please re-check once again ad let  me know if there are any queries?

 

Please mark the answer as correct if it suffice your query.

 

Thanks

Soumita.

Hi Soumita,

Thanks for that - I've removed that line, and am still not getting the opened_by to update on tasks. Would replacing that line with something else work? I don't want to run an 'active', true query, as I also want it to pick up tasks that are closed.

Cheers,

Anna

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.