- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-14-2021 09:43 PM
When we create a survey to trigger it we have given a trigger condition but in that the 'Auto assessment business rule' Bussiness rule which should auto generate but is not generating OOB. And when we try to create and attache it it is not working for custom bussiness rule.
Please help if any solution you have.
Thank you.
Solved! Go to Solution.
- Labels:
-
Survey Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-17-2021 01:41 AM
Glad that the approach I shared helped you debug.
Why is it missing?
It is out of the box and should be present unless someone removed it manually.
Please find the function below and add it to the script include
updateTriggerConditionBR: function(triggerCondition) {
var override = '';
if (!triggerCondition.business_rule.nil()) {
var pMgr = new GlidePluginManager();
var isDomainSeparationActive = pMgr.isActive('com.glide.domain.msp_extensions.installer');
if (isDomainSeparationActive) {
var userDomain = gs.getUser().getDomainID();
userDomain = userDomain || 'global'; // if user domain is null, use global
if (userDomain != triggerCondition.business_rule.sys_domain) {
override = triggerCondition.business_rule + '';
triggerCondition.business_rule = '';
}
}
}
var escapeCondition = triggerCondition.condition.toString();
escapeCondition = escapeCondition.replace(/[\'\"]/g, "\\'");
var brCondition = "(new global.AssessmentUtils().conditionCheck(current, '" + escapeCondition + "'))";
var br;
if (!triggerCondition.business_rule.nil())
br = triggerCondition.business_rule.getRefRecord();
else {
br = new GlideRecord('sys_script');
br.initialize();
}
br.name = 'Auto assessment business rule';
br.action_insert = true;
br.action_update = true;
br.active = true;
br.when = 'after';
br.execute_function = true;
br.order = 300;
br.collection = triggerCondition.table;
if (brCondition.length <= 254) {
br.condition = brCondition;
br.script = "function onAfter(){ \n (new sn_assessment_core.AssessmentCreation()).conditionTrigger(current, '" + triggerCondition.sys_id + "'); \n }";
} else {
br.condition = "";
br.when = "after";
br.script = "function onAfter(){ \n if (" + brCondition + ") \n (new sn_assessment_core.AssessmentCreation()).conditionTrigger(current, '" + triggerCondition.sys_id + "'); \n }";
}
if (override)
br.sys_overrides = override;
if (triggerCondition.business_rule.nil()) {
var brId = br.insert();
triggerCondition.business_rule = brId;
triggerCondition.setWorkflow(false);
triggerCondition.update();
triggerCondition.setWorkflow(true);
} else
br.update();
},
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-17-2021 01:41 AM
Glad that the approach I shared helped you debug.
Why is it missing?
It is out of the box and should be present unless someone removed it manually.
Please find the function below and add it to the script include
updateTriggerConditionBR: function(triggerCondition) {
var override = '';
if (!triggerCondition.business_rule.nil()) {
var pMgr = new GlidePluginManager();
var isDomainSeparationActive = pMgr.isActive('com.glide.domain.msp_extensions.installer');
if (isDomainSeparationActive) {
var userDomain = gs.getUser().getDomainID();
userDomain = userDomain || 'global'; // if user domain is null, use global
if (userDomain != triggerCondition.business_rule.sys_domain) {
override = triggerCondition.business_rule + '';
triggerCondition.business_rule = '';
}
}
}
var escapeCondition = triggerCondition.condition.toString();
escapeCondition = escapeCondition.replace(/[\'\"]/g, "\\'");
var brCondition = "(new global.AssessmentUtils().conditionCheck(current, '" + escapeCondition + "'))";
var br;
if (!triggerCondition.business_rule.nil())
br = triggerCondition.business_rule.getRefRecord();
else {
br = new GlideRecord('sys_script');
br.initialize();
}
br.name = 'Auto assessment business rule';
br.action_insert = true;
br.action_update = true;
br.active = true;
br.when = 'after';
br.execute_function = true;
br.order = 300;
br.collection = triggerCondition.table;
if (brCondition.length <= 254) {
br.condition = brCondition;
br.script = "function onAfter(){ \n (new sn_assessment_core.AssessmentCreation()).conditionTrigger(current, '" + triggerCondition.sys_id + "'); \n }";
} else {
br.condition = "";
br.when = "after";
br.script = "function onAfter(){ \n if (" + brCondition + ") \n (new sn_assessment_core.AssessmentCreation()).conditionTrigger(current, '" + triggerCondition.sys_id + "'); \n }";
}
if (override)
br.sys_overrides = override;
if (triggerCondition.business_rule.nil()) {
var brId = br.insert();
triggerCondition.business_rule = brId;
triggerCondition.setWorkflow(false);
triggerCondition.update();
triggerCondition.setWorkflow(true);
} else
br.update();
},
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-17-2021 01:54 AM
Will it get change during upgrade?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-17-2021 02:13 AM
Yes it will be skipped during upgrade if you update the OOB.
But there is this way to allow this component to get updated when the next upgrade happens
Overwrite customizations during an upgrade
Procedure
- Open the customized object (for example, the ArrayUtil script include).
- Right-click the header and select Show Latest Update.
- Configure the form to add the Replace on upgrade field, if necessary.
- Select the Replace on upgrade check box and click Update.
The customized object will be replaced on the next upgrade.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â11-30-2022 03:35 PM
I have a similar issue. I have one Survey that has two triggers, but the auto assessment business rule only looks at one of the triggers. How do we make it look at both? The survey should fire for different triggers:
Trigger 1: certain HR Services; recipient: opened_for
Trigger 2: different HR Services: recipient: subject_person
Only the second trigger is being passed to that BR but we need the other one to go also. Why have multiple triggers if the BR only uses the first one you create?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-17-2021 01:43 AM
If my response helped you please mark it correct to close the question so that it benefits future readers as well.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader