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 - last edited 3 weeks ago
Hi @Ankur Bawiskar
thanks for the responce
please find below details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
both the business rules should be after update and not Before update.
Also which business rule is not working?
did you debug by adding gs.info()?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Ankur Bawiskar
changed to after BR but still facing same issue
and two business rule triggering 2 times
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try to use setWorkflow(false) just before the update in both the business rules
something like this
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.setWorkflow(false);
oldProblem.update();
}
return;
}
var problemGr = new GlideRecord('problem');
if (problemGr.get(problemId)) {
problemGr.setValue('rfc', changeGr.sys_id);
problemGr.autoSysFields(false);
problemGr.setWorkflow(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.setWorkflow(false);
oldChange.update();
}
return;
}
var changeGr = new GlideRecord('change_request');
if (changeGr.get(changeId)) {
changeGr.setValue('parent', problemG.sys_id);
changeGr.autoSysFields(false);
changeGr.setWorkflow(false);
changeGr.update();
}
},
type: 'SyncChangeProblem'
};
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