- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 08:41 AM
When I am on the Incident form, go down to the "incident_tasks" related lists, and click the new button.
It creates a new task, but it doesn't create the relationship between the task and the incident. What do I need to do to make that relationship automatic?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 09:15 AM
t looks like when you click "New" under the Incident Tasks related list, a new task is created, but the Incident field is not automatically populated. To fix this and establish the relationship automatically, follow these steps:
Solution: Use a Business Rule or Client Script
Option 1: Business Rule (Recommended)
Navigate to System Definition > Business Rules.
Click New.
Configure the rule as follows:
- Name: Auto-populate Incident Field
- Table: Task (or incident_task if applicable)
- Advanced: (Check the Advanced box)
In the When to run section:
- When: Before
- Insert: (Check this option)
In the Script tab, add the following script:
if (!current.incident && current.parent) { current.incident = current.parent; }Click Save or Submit.
Option 2: Client Script (For Immediate UI Update)
Navigate to System Definition > Client Scripts.
Click New.
Configure the script:
- Name: Auto-fill Incident Field
- Table: incident_task
- Type: onLoad
Add this script:
(function executeRule(current, gForm, gSNC) { var incidentSysId = gForm.getParameter('sysparm_parent'); if (incidentSysId) { gForm.setValue('incident', incidentSysId); } })(current, gForm, gSNC);Click Save.
Hope this works for you.
- The Business Rule ensures the task is linked before it is inserted into the database.
- The Client Script updates the UI immediately when a new task form is opened.
Kindly mark it as "Accepted Solution"/"helpful", as it resolves your query. Please press like button for the resolution provided.
With Regards,
Krishna Kumar M - Talk with AIT3ch
LinkedIn: https://www.linkedin.com/in/mkrishnak4/
YouTube: https://www.youtube.com/@KrishAIT3CH
Topmate: https://topmate.io/mkrishnak4 [ Connect for 1-1 Session]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 09:15 AM
t looks like when you click "New" under the Incident Tasks related list, a new task is created, but the Incident field is not automatically populated. To fix this and establish the relationship automatically, follow these steps:
Solution: Use a Business Rule or Client Script
Option 1: Business Rule (Recommended)
Navigate to System Definition > Business Rules.
Click New.
Configure the rule as follows:
- Name: Auto-populate Incident Field
- Table: Task (or incident_task if applicable)
- Advanced: (Check the Advanced box)
In the When to run section:
- When: Before
- Insert: (Check this option)
In the Script tab, add the following script:
if (!current.incident && current.parent) { current.incident = current.parent; }Click Save or Submit.
Option 2: Client Script (For Immediate UI Update)
Navigate to System Definition > Client Scripts.
Click New.
Configure the script:
- Name: Auto-fill Incident Field
- Table: incident_task
- Type: onLoad
Add this script:
(function executeRule(current, gForm, gSNC) { var incidentSysId = gForm.getParameter('sysparm_parent'); if (incidentSysId) { gForm.setValue('incident', incidentSysId); } })(current, gForm, gSNC);Click Save.
Hope this works for you.
- The Business Rule ensures the task is linked before it is inserted into the database.
- The Client Script updates the UI immediately when a new task form is opened.
Kindly mark it as "Accepted Solution"/"helpful", as it resolves your query. Please press like button for the resolution provided.
With Regards,
Krishna Kumar M - Talk with AIT3ch
LinkedIn: https://www.linkedin.com/in/mkrishnak4/
YouTube: https://www.youtube.com/@KrishAIT3CH
Topmate: https://topmate.io/mkrishnak4 [ Connect for 1-1 Session]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2025 09:18 AM
Hi @Scott29
It should display the incident number. If it doesn't, you need to add the logic to the new button, where it should map these two fields.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************