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

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

Yes, that is correct, please make use of description field also:



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


Also make the BR onAfter, since you have to wait until the Request Item is created.


Hi,



I have created a BR similar to yours but it is not creating a Catalog Task. My instance is a Domain Separated instance. Since, I want this to happen in all domains, I have created the below BR in the global domain.



This is my BR:



Screenshot (680).png



Screenshot (681).png



What mistake am I doing? Please let me know.


See below script:


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

Thank you,


Ashutosh


Hi Ashutosh,



I have changed the script by pushing the gr.iniatialize(); to the second line. But, still the Catalog Task is not getting created.