Tasks do not have the RITM already prefilled

Servicenow de11
Tera Contributor

Hello,

Sourcing tasks do not have the RITM already prefilled. Because of this we, need to open the REQ and see what the RITM number is, copy it, go back to the task and paste it just to source an item. Attached screenshot
Note: The task is to created based on Request table workflow not RITM Workflow. so RITM number is not auto populated.

Can anyone suggest me the script to autopopulate the RITM Number in Task record

Thanks in advance

 

1 ACCEPTED SOLUTION

Ok .

Create after insert BR on sc_task and add following script in it:

 

var getRITM = new GlideRecord('sc_req_item');
getRITM.addQuery('request',current.request);
getRITM.query();
if(getRITM.next()){
current.request_item = getRITM.sys_id;
current.update();
}

 

and then test !

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

14 REPLIES 14

jMarshal
Mega Sage
Mega Sage

Are you using legacy workflow or flow designer for this?

We are using workflow

sushantmalsure
Mega Sage
Mega Sage

See you can have a after insert BR on sc_task which can look for RITM created from request.

But you will face an issue when you will come across order guide when there are multiple RITMs are present below request.

 

So considering this fact and issue you are into I might have suggested to make this BR only run for  specific catalog item but neither sc_request OR sc_task has item field which can tell you details about catalog item (OOB).

 

Because of this I think you need to shift your workflow on sc_req_item, which will automatically solve your problem.

 

There is a  possibility of using parent field from sc_task, can you check if it is empty OR have request populated? if empty or request number is there then you have no other option apart from shifting the workflow to sc_req_item BUT if it has RITM number populated (which likely not) then in after insert BR on sc_task, you can set value of requested item from parent field (with condition of catalog item . walked from parent).

 

Hope you get it

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

I cant shift the workflow to sc_req_item table because we have another workflow for RITM Table.

 

RITM approval is approved after that request table workflow task will trigger based on two conditions:

If the request is sourceable  and approval is approved

If this two conditions matches that request table workflow task will trigger