- 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-14-2021 09:56 PM
Hi,
Is the 'Auto assessment business rule' not working for any survey or only for your custom survey?
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-14-2021 09:59 PM
For my survey and again after this I tried to create another survey and added a trigger condition for this also it is not working But surveys that are already there for them the Bussiness rule is there .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2021 10:07 PM
Hi,
Did you check the survey trigger condition got matched?
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-14-2021 10:10 PM
Hi,
Yes, All that trigger conditions got matched but in the trigger condition the bussiness rule field is empty for now whic should be auto created.