- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2024 03:40 AM
Need to create a reference field in problem form named as related incident which will refer incident table and on selecting an incident number on that field. After saving the form in the related incident in problem table, that selected incident will be shown in that particular problem once opened with field name as related incident and vice-versa. When related problem is selected in incident table it should be shown in that incident page once opened .
Please let me know how it can be achieved?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 02:00 AM
Hi @RohitKumar24 ,
It looks like your requirement is for a Bidirectional Relationship between the Incident and Problem tables in ServiceNow. This means that if an incident is related to a problem, that relationship should reflect both ways—whether linked from the incident side or the problem side.
Here's a summary and steps to implement this:
1. Create a Reference Field in the Problem Table
- Name: u_related_incident (using u_ prefix to denote a custom field)
- Label: "Related Incident"
2. Related Problem Reference Field is already exist in the Incident Table
3. Business Rule for Synchronizing the Relationship
You'll need to create a Business Rule to maintain the synchronization between the two tables. Here's an example:
3.1 Business Rule on Problem Table
- Table: Problem
- When to Run: before Insert/Update
- Condition: u_related_incident is not empty.
- Script:
var relatedIncident = new GlideRecord('incident');
if (relatedIncident.get(current.u_related_incident)) {
relatedIncident.problem_id = current.sys_id;
relatedIncident.update();
}
3.2 Business Rule on Incident Table
- Table: Incident
- When to Run: before Insert/Update
- Condition: problem_id is not empty.
- Script:
var relatedProblem = new GlideRecord('problem');
if (relatedProblem.get(current.u_related_problem)) {
// Set the related incident field on the Problem record
relatedProblem.u_related_incident = current.sys_id;
relatedProblem.update();
}
Regards,
Ayan Murshad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 02:00 AM
Hi @RohitKumar24 ,
It looks like your requirement is for a Bidirectional Relationship between the Incident and Problem tables in ServiceNow. This means that if an incident is related to a problem, that relationship should reflect both ways—whether linked from the incident side or the problem side.
Here's a summary and steps to implement this:
1. Create a Reference Field in the Problem Table
- Name: u_related_incident (using u_ prefix to denote a custom field)
- Label: "Related Incident"
2. Related Problem Reference Field is already exist in the Incident Table
3. Business Rule for Synchronizing the Relationship
You'll need to create a Business Rule to maintain the synchronization between the two tables. Here's an example:
3.1 Business Rule on Problem Table
- Table: Problem
- When to Run: before Insert/Update
- Condition: u_related_incident is not empty.
- Script:
var relatedIncident = new GlideRecord('incident');
if (relatedIncident.get(current.u_related_incident)) {
relatedIncident.problem_id = current.sys_id;
relatedIncident.update();
}
3.2 Business Rule on Incident Table
- Table: Incident
- When to Run: before Insert/Update
- Condition: problem_id is not empty.
- Script:
var relatedProblem = new GlideRecord('problem');
if (relatedProblem.get(current.u_related_problem)) {
// Set the related incident field on the Problem record
relatedProblem.u_related_incident = current.sys_id;
relatedProblem.update();
}
Regards,
Ayan Murshad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 12:11 AM
Thanks Ayan, for the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2024 02:29 AM
Hi @RohitKumar24 ,
It available OOB.
From incident form if you add problem from related list section then it will start reflecting in related list on problem form.
From Problem to Incident you can bring "Parent" field on form and select incident number then it will start reflecting on related list of incident form.
If you want that parent filed should only show the incident then you can do dictionary override.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 02:56 AM
Thanks Runjay