How to associate SCTASK/Incident records with Projects in SPM without using parent field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We want to configure our Assignment Rules and SLAs based on the Project. Although we have a Project variable available on the frontend catalog form, we are unable to identify any dedicated field at the SCTASK/Incident level where this Project information can be stored and used for backend logic.
Points to note:
We do not want to rely on variables using “Show Related Fields,” as using variables directly for such logic is not future-proof.
While the Parent field is available, it is already used for multiple relationships such as ENHNC, REQ, etc. Currently, SCTASK records are linked with RITMs through the Parent field, and in future, if Enhancement and SCTASK relationships are introduced, this approach may create conflicts and ambiguity.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
ahoy @ATRIVEDI,
there are quite plenty options here. But what I would try as the first option is to map the variable called Project to a Parent field.
Which means if you submit that catalog item, the value from the Project variable will be added to the Parent field. Ensure that the variable and target field are of the same type (e.g. reference using sys ID on the same table).
Either on the variable definition go with Map to field: true & Map the field like this:
Or in the script field (depends on the table of your catalog item x record producer):
current.backend_field = producer.variable_name;
Answers generated by GlideFather. Check for accuracy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @ATRIVEDI
If you do not "want to rely on variables using “Show Related Fields"
In that case,
open the Incident and sc_task tables.
- Create a new field with the following properties:
- Type: Reference
- Reference: Project [pm_project]
- Column Label: Project (like u_project)
- Create an After-Insert Business Rule on sc_req_item.
Condition: current.variables.project_variable_name != '' (Replace with your actual variable name).
Sample code/update as per your requirement:
(function executeRule(current, previous /*null when async*/) {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.query();
while (sctask.next()) {
sctask.u_project = current.variables.project_variable_name; // Set your custom field
sctask.update();
}
})(current, previous);
- In Service Level Management > SLAs > SLA Definitions, set the start condition to evaluate Project .
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti