- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 09:03 AM
HI
There is requirement need to create related list on Problem
Where Problem - Change Request (related list) and also problem have "Change request" (if add in the form)
When you create from problem - hamburger - "Create standard Change" UI action that appears is --> -->"Change Request (Problem form have that field only it appear over there only)
Relationship /sys_m2m.list
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 09:27 AM
Base on the scenario use case you have mentioned, I am assuming that you are trying to create a related list on the Problem form that shows Change Requests in two scenarios:
Standard relationship: Change Requests that are directly related to the Problem via a field (e.g., problem_id on the Change Request table).
M2M relationship: Change Requests linked via a many-to-many (M2M) relationship (like when using the "Create Standard Change" UI action).
Please try either:
Create a custom related list that shows both sets of Change Requests together.
Or create two separate related lists if merging is not possible.
Requirements:
Display Change Requests on Problem form via:
A direct field (one-to-many).
A many-to-many relationship (sys_m2m).
Triggered by "Create Standard Change" UI action, which sets the M2M.
Option 1: Use a Filtered Related List
If the Change Requests are all in the change_request table but related in different ways, you can create a filtered related list.
We need to:
Create a Database View or use a custom GlideRecord query (if scripting).
Use a Related List via the sys_relationship table (sys_relationship.list).
Setup in sys_relationship:
Go to: System Definition > Relationships
Create a new relationship:
Name: Change Requests from Problem
Applies to: problem
Related table: change_request
Query with script: check the box
Use this script:
(function executeRule(current, parent) {
var rfc = parent.u_change_request; // Field holding reference to single Change Request
var gr = new GlideRecord('change_request');
gr.addQuery('problem_id', parent.sys_id); // or whatever direct relationship field is
if (rfc) {
gr.addOrCondition('sys_id', rfc);
}
return gr;
})(current, parent);
This shows Change Requests where:
problem_id equals current problem
OR sys_id equals the value in a field (like u_change_request or change_request)
If we are using M2M Table
If "Create Standard Change" creates an M2M entry (e.g., change_request_problem), you can:
Go to sys_m2m.list
Find or create M2M:
Table: problem
M2M Table: e.g., change_request_problem
Ensure change_request is on that table and correctly mapped.
Then, just add the M2M related list to the Problem form layout:
Form Layout → Related Lists tab → Add "Change Request Problem"
Method How
Direct Related List | Use problem_id on change_request |
Custom Related List | Use sys_relationship with query script |
M2M Related List | Use sys_m2m table like change_request_problem |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 09:27 AM
Base on the scenario use case you have mentioned, I am assuming that you are trying to create a related list on the Problem form that shows Change Requests in two scenarios:
Standard relationship: Change Requests that are directly related to the Problem via a field (e.g., problem_id on the Change Request table).
M2M relationship: Change Requests linked via a many-to-many (M2M) relationship (like when using the "Create Standard Change" UI action).
Please try either:
Create a custom related list that shows both sets of Change Requests together.
Or create two separate related lists if merging is not possible.
Requirements:
Display Change Requests on Problem form via:
A direct field (one-to-many).
A many-to-many relationship (sys_m2m).
Triggered by "Create Standard Change" UI action, which sets the M2M.
Option 1: Use a Filtered Related List
If the Change Requests are all in the change_request table but related in different ways, you can create a filtered related list.
We need to:
Create a Database View or use a custom GlideRecord query (if scripting).
Use a Related List via the sys_relationship table (sys_relationship.list).
Setup in sys_relationship:
Go to: System Definition > Relationships
Create a new relationship:
Name: Change Requests from Problem
Applies to: problem
Related table: change_request
Query with script: check the box
Use this script:
(function executeRule(current, parent) {
var rfc = parent.u_change_request; // Field holding reference to single Change Request
var gr = new GlideRecord('change_request');
gr.addQuery('problem_id', parent.sys_id); // or whatever direct relationship field is
if (rfc) {
gr.addOrCondition('sys_id', rfc);
}
return gr;
})(current, parent);
This shows Change Requests where:
problem_id equals current problem
OR sys_id equals the value in a field (like u_change_request or change_request)
If we are using M2M Table
If "Create Standard Change" creates an M2M entry (e.g., change_request_problem), you can:
Go to sys_m2m.list
Find or create M2M:
Table: problem
M2M Table: e.g., change_request_problem
Ensure change_request is on that table and correctly mapped.
Then, just add the M2M related list to the Problem form layout:
Form Layout → Related Lists tab → Add "Change Request Problem"
Method How
Direct Related List | Use problem_id on change_request |
Custom Related List | Use sys_relationship with query script |
M2M Related List | Use sys_m2m table like change_request_problem |