The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Trying to automatically create a Catalog Task when a RITM is created

prudhvig
Tera Expert

Hi,

I have developed a catalog item which when filled and submitted would create a Request and RITM under it. Along with this, I want a Catalog Task to be automatically created with a description "Default Task".

I am quite new to Servicenow and unable to find a way to solve this. Please help.

Thanks in advance.

1 ACCEPTED SOLUTION

Oh My Mistake.



Try this:



  1. var gr = new GlideRecord('sc_task');
  2. gr.initialize();
  3. gr.request_item = current.sys_id;
  4. gr.short_description = "Sample Description";
  5. gr.description = "Sample Description"
  6. gr.insert();

View solution in original post

18 REPLIES 18

var gr = new GlideRecord('sc_task');


gr.initialize();


gr.short_description = 'Demo';


gr.request_item = current.getValue(sys_id);


gr.insert();



You must pass the RITM also so that it appears in the related list of the RITM.



And initialize if used after the variable set then it just wipes away the set fields. Hope this helps



Please read and use this if needed GlideRecord Cheat Sheet - ServiceHow


Surendra Raika1
Kilo Guru

var gr = new GlideRecord('sc_task');


gr.initialize();


gr.short_description = 'Demo';


gr.request_item = current.getValue(sys_id);


gr.insert();



You must pass the RITM also so that it appears in the related list of the RITM.



And initialize if used after the variable set then it just wipes away the set fields. Hope this helps



Please read and use this if needed GlideRecord Cheat Sheet - ServiceHow



Regards
SR


Hi Surendra,



I have used your script too. But, it is not creating a Catalog Task.


Mujtaba Amin Bh
Mega Guru

Use below script:



(function executeRule(current, previous /*null when async*/) {


var gr = new GlideRecord('sc_task');


gr.initialize();


gr.short_description = 'Demo short description';


gr.description = "Test description";


gr.request_item = current.sys_id;


gr.parent = current.sys_id;


gr.insert();


})(current, previous);



And below conditions in the BR,


find_real_file.png



find_real_file.png