- 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 10:23 PM
Hi,
It should be auto-populated for new and existing Trigger Condition.
Because the BR field is empty the survey is not triggering
1) For new trigger condition the BR field is set during insertion
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 11:10 PM
Yes , But for new trigger condition is also the BR is not auto-populating ,so any idea why is instace behaving different?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2021 11:19 PM
Hi,
please check any before insert BR or default value is not setting it
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 11:31 PM
Does your instance have that OOB business rule?
Did somebody remove that or inactivated that
The logic which sets the BR on the trigger condition is from this BR
Name: Generate assessment trigger condition
Script Include: AssessmentUtils
Function: updateTriggerConditionBR
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:31 AM
Thanks Ankur, The updateTriggerConditionBR Function is missing but why is so ! and if we add it manually will cause issue during upgrade right? so what will be best approach? Could you please help us on this.
Thank you.