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

ok then what do you have in parent field of sc_task ? is it RITM or REQ?

 

 

On a side note: why cant you handle approval and task creation (post approval) in the same workflow which you have on RITM?

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

In sc_task table we have request number and we need RITM Number also autopopulated

 

That RITM workflow is a different thing after purchase field update another tasks will trigger.

Attached image



is the sc_task in question (the one which needs the ritm number populated, but isn't) the task which is created in the workflow you attached there? ("Task for transfer allocation")...or is a different task? perhaps one that was created via previous workflow before this ritm workflow runs?

There is a parent field also on task table.
Open any such task where RITM is missing. Right click header and click on Show XML, then locate the parent field and tell me what does the parent field has as value RITM or REQ?

Based on your answer I will give you a script to run in business rule.

 

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

Parent field is REQUEST