- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2024 04:37 AM
Hello,
I have a requirement to add an Edit button in Affected CIs related list on a change task on CSM workspace and to have the same functionality like the backend Edit button.
Currently we have a custom Edit button on change task that applies a filter to only show Affected CIs that are present in the parent (change request)
Example:
Change request CHG0000011 has only 1 affected CI and one change task CTASK0010054
If I open the change task CTASK0010054 I can see all the details and in the Affected CIs related list the custom Edit button
If I click on the Edit button, I have an applied filter to only show Affected CIs that are present in the parent (CHG0000011):
I need to create a button that does the same logic in CSM and SOW workspaces.
Does anybody know how to achieve that?
Thank you,
Elena
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 06:19 AM
Managed to solve it!
Here is the solution:
Backend EDIT:
Insert&stay the existing OOTB "Edit..." button to which I've added the following logic:
Code:
var uri = action.getGlideURI();
var path = uri.getFileFromPath();
var type = parent.getValue('type');
uri.set('sysparm_m2m_ref', current.getTableName());
uri.set('sysparm_stack', 'no');
//get the change task sys id
var m2mObject = uri.toString('sys_m2m_template.do');
var firstSplit = m2mObject.split('collectionID=');
var secondSplit = firstSplit[1].split('&sysparm_collection_key');
var changeTaskSysId = secondSplit[0] + '';
//get the change request sys id
var changeRequest;
var grGetChangeRequest = new GlideRecord('change_task');
if (grGetChangeRequest.get(changeTaskSysId)) {
changeRequest = grGetChangeRequest.change_request + '';
affectedCIChangeTask();
}
function affectedCIChangeTask() {
var parentAffectedCIs = new changeTaskUtils().getCIsFromChangeRequest(changeRequest);
if (parentAffectedCIs) {
uri.set('sysparm_query', 'sys_idIN' + parentAffectedCIs);
uri.set('jvar_no_filter', 'true');
}
}
action.setRedirectURL(uri.toString('sys_m2m_template.do'));
Script include changeTaskUtils:
Code:
Workspaces EDIT:
Created a declarative action "Edit...":
Code:
Code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 06:19 AM
Managed to solve it!
Here is the solution:
Backend EDIT:
Insert&stay the existing OOTB "Edit..." button to which I've added the following logic:
Code:
var uri = action.getGlideURI();
var path = uri.getFileFromPath();
var type = parent.getValue('type');
uri.set('sysparm_m2m_ref', current.getTableName());
uri.set('sysparm_stack', 'no');
//get the change task sys id
var m2mObject = uri.toString('sys_m2m_template.do');
var firstSplit = m2mObject.split('collectionID=');
var secondSplit = firstSplit[1].split('&sysparm_collection_key');
var changeTaskSysId = secondSplit[0] + '';
//get the change request sys id
var changeRequest;
var grGetChangeRequest = new GlideRecord('change_task');
if (grGetChangeRequest.get(changeTaskSysId)) {
changeRequest = grGetChangeRequest.change_request + '';
affectedCIChangeTask();
}
function affectedCIChangeTask() {
var parentAffectedCIs = new changeTaskUtils().getCIsFromChangeRequest(changeRequest);
if (parentAffectedCIs) {
uri.set('sysparm_query', 'sys_idIN' + parentAffectedCIs);
uri.set('jvar_no_filter', 'true');
}
}
action.setRedirectURL(uri.toString('sys_m2m_template.do'));
Script include changeTaskUtils:
Code:
Workspaces EDIT:
Created a declarative action "Edit...":
Code:
Code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @Elena Spıru ,
First of all, thanks for the article! I'm using this approach on another related list, and it works well overall. However, I’ve encountered an issue with the inner buttons of the sys_m2m_template window (Save and Cancel).
When I click the Save button, the window should close and refresh the related list of the SOW, and when I click Cancel, it should simply close the window.
Unfortunately, these buttons aren’t responding.
Have you found any solution for this?
