attach problem to change related list and vise versa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Team
To implement above requirement i have created 2 before business rule and one script include
the below code is working when we add only one problem or one change to problem or change related list but if we add two or multiple at a time by selecting check box from problem/change related list then this code is not executing as expected
var SyncChangeProblem = Class.create();
SyncChangeProblem.prototype = {
initialize: function() {},
syncFromChangeRequest: function(changeGr, oldParentId) {
var problemId = changeGr.parent;
if (!problemId && oldParentId) {
var oldProblem = new GlideRecord('problem');
if (oldProblem.get(oldParentId)) {
oldProblem.setValue('rfc', '');
oldProblem.autoSysFields(false);
oldProblem.update();
}
return;
}
var problemGr = new GlideRecord('problem');
if (problemGr.get(problemId)) {
problemGr.setValue('rfc', changeGr.sys_id);
problemGr.autoSysFields(false);
problemGr.update();
}
},
syncFromProblem: function(problemG, oldchgreqId) {
var changeId = problemG.rfc;
if (!changeId && oldchgreqId) {
var oldChange = new GlideRecord('change_request');
if (oldChange.get(oldchgreqId)) {
oldChange.setValue('parent', '');
oldChange.autoSysFields(false);
oldChange.update();
}
return;
}
var changeGr = new GlideRecord('change_request');
if (changeGr.get(changeId)) {
changeGr.setValue('parent', problemG.sys_id);
changeGr.autoSysFields(false);
changeGr.update();
}
},
type: 'SyncChangeProblem'
};
Please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RamuN
the below code is working when we add only one problem or one change to problem or change related list but if we add two or multiple at a time by selecting check box from problem/change related list then this code is not executing as expected
Atul:It is OOTB and working as designed, so I recommend not making any changes here. Doing so could spoil the basic functionality.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you for quick response
This are custom configurations which is created by me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RamuN I respect your customization, but indirectly you are breaking the OOTB functionality. As per OOTB, it is 1 PRB → 1 Change, and if you add more than that, you would need to create an M2M table, which might work. As a consultant, I recommend not moving forward with this change without discussing it with the relevant stakeholders and guiding them accordingly.
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
sorry but you didn't share which business rule is calling which function.
share those details.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader