The Now Platform® Washington DC release is live. Watch now!
11-02-2016 01:36 PM
Hello,
This is a Demand question on the Create OnDemand Assessment business rule. I recently posted a similar question about sending different stakeholders different assessments:
We are setting up Demand, and want our Business Stakeholders to receive "Assessment A", and our IT people to receive "Assessment B". Is there a way to do this out of box that I am missing? I know how to accomplish this via a customization, but before I do that I wanted to check and see if there is an out of box configuration to do this.
The answer I got was there is nothing out of the box that does this, so I will need to modify the business rule. So, this is what I did:
gs.addInfoMessage('Assessments Created');
var gr = new GlideRecord('dmn_m2m_demand_stakeholder');
var encodedQuery = "demand=" + current.sys_id + "^stakeholder.assessment=yes";
gr.addEncodedQuery(encodedQuery);
gr.query();
var userIds = "";
while (gr.next()) {
if (!JSUtil.nil(userIds))
userIds += ",";
userIds += gr.stakeholder.user.sys_id;
gs.addInfoMessage('userId ' + userIds);
gs.addInfoMessage('user ' + gr.stakeholder.user);
gs.addInfoMessage('type ' + gr.stakeholder.u_assessment_type); //sometimes this shows the type and sometimes it does not
}
if (!JSUtil.nil(userIds) && (gr.stakeholder.u_assessment_type = 'bvs')){
//create Business Value Score assessments for the list of users
(new SNC.AssessmentCreation()).createAssessments('0556fa9a8f12110040f82ab2f0f923f8', current.sys_id, userIds, false, "");
} else if (!JSUtil.nil(userIds) && (gr.stakeholder.u_assessment_type = 'risk')){
//create Risk assessments for the list of users
(new SNC.AssessmentCreation()).createAssessments('a150471e6ff622004c3e841dba3ee407', current.sys_id, userIds, false, "");
}else{
//make sure to generate the ondemand assessments for the case where there are no stakeholders
//bvs
(new SNC.AssessmentCreation()).createAssessments('0556fa9a8f12110040f82ab2f0f923f8',current.sys_id, gs.getUser().getRecord().getValue("sys_id"), false, "");
//risk
(new SNC.AssessmentCreation()).createAssessments('a150471e6ff622004c3e841dba3ee407',current.sys_id, gs.getUser().getRecord().getValue("sys_id"), false, "");
}
Based on the messages, I can tell the Assessment Type is being read, so why isn't my "if" statement working? All the stakeholders are getting the Business Value Scorecard. One stakeholder should be getting the Risk assessment.
Please and thank you in advance!
Laurie
11-02-2016 03:26 PM
Hey Laurie,
The problem is in the if condition, instead of checking you are assigning value to Assessment Type. Same issue in the else if condition.
Do modify the code as such -:
11-03-2016 10:54 AM
Hey Nitish,
Thank you for your response! I can't believe I did that! Anyway, it did not fix my original issue of how to generate two different assessments based on Assessment Type field. Any ideas on that? I'm thinking it has to do with a filter on the metric category or metric type fields.
Thanks,
Laurie
11-03-2016 03:23 PM
Hey Laurie,
After the code I just saw your query "why isn't my "if" statement working?" (felt sleepy @ the moment). Apologies for the same.
Could you try tweaking your code as follows -:
11-07-2016 10:41 AM
Hi Nitish - I think figured out the issue and it's not with the business rule. I opened a ticket with ServiceNow just to be sure of what I think the issue is. I will post a response when I get one.
I appreciate your help!
Laurie