- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 01:32 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 03:22 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 03:31 AM
Hi @Sai Kumar B @Ankur Bawiskar @SanjivMeher
Even after making changes as suggested, still task is not creating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 01:55 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 03:24 AM - edited 10-13-2022 03:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 03:38 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 04:00 AM
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