Create task in case table using client script/ business rule.

Abhijit Das7
Tera Expert

Hi Everyone,

I have created template for case table. Whenever I use this template and create case , then automatically task should be created in case table (CSTASK0010003). Can anyone help me to guide write client script/ business rule to generate task.

Any reference regarding this .

 

Thanks in advance 

cc : @Ankur Bawiskar 

1 ACCEPTED SOLUTION

@Abhijit Das7 

in the parent field you should set the case sysId and not number

gr.parent = current.getUniqueValue();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Hi @Sai Kumar B @Ankur Bawiskar @SanjivMeher 

 

Even after making changes as suggested, still task is not creating.

Sai Kumar B
Mega Sage
Mega Sage

@Abhijit Das7 

I don't think we have any OOB filed that stores the applied template name so, I would suggest you create a Case task whenever any template field changes on the parent case record. 

1.) Create a before/update BR
2.) Give Condition as Field(The field should be template field) changes
3.) In script, create Case task record 

SanjivMeher
Kilo Patron
Kilo Patron

You need to fix line 7 in your script. it should be

gr.parent = current.sys_id;

 

Also check if removing the BR condition makes it work.


Please mark this response as correct or helpful if it assisted you with your question.

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

As others have suggested parent is a reference field so please use the below in your code:-

 

gr.parent = current.sys_id;

 

Also don't just copy assigned_to copy both assignment group and assigned_to as below:-

 

gr.assignment_group = current.assignment_group;
gr.assigned_to = current.assigned_to;

 

Please mark my answer as correct based on Impact. 

Baala T
Mega Guru

Hi Abhijit,

 

Try with below steps,

 

- Create a reference field called "Template Used" in Case Table, referring Template [sys_template] table

- Add this "Template Used" field in your case form, make it hidden

- Create a Template by adding the "Template Used" field with the value of "Template Name"

- Now when you apply the template system automatically populates the "Template Used" field value of the "Template Name"

- Create an Insert business rule with the trigger condition as "Template Used" value is "Name of the template" to create a Task record.

 

Please do keep me posted if there is any challenge.

 

Regards,

Bala T