Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

widget not showing all Pending action items

JVINAY
Tera Contributor

Hi  Team,

 

I want to display privacy production name also in pending widgets, but currently it is not getting displayed like other 4 checklists

 

Please help me how to fix this.

 

Script :

 

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.table = $sp.getParameter("table");
data.sys_id = $sp.getParameter("sys_id");
data.wfActivities = [];

if (!data.sys_id) return;
if (!data.table) return;


if (input && input.action == 'fetch_wf_activities') {
var isCIRv2 = false;
var hideIds = gs.getProperty('central_intake.portal.hide_wf_activity_names');
//console.log('test: ' + hideIds.indexOf('5de83f221b6af050ce4385d0604bcb56'));
var intake_accs = [];
intake_accs.push(data.sys_id);

var acc = new GlideRecord('u_cloud_intake');
acc.addQuery('parent', data.sys_id);
acc.query();
while (acc.next()) {
intake_accs.push(acc.getUniqueValue());
}


try {
var cir = new GlideRecord('u_cloud_intake_request');
if (cir.get(data.sys_id)) {
if (cir.u_cir_v2 && cir.u_cir_v2.toString() == 'true') {
isCIRv2 = true;
}
}
} catch (p) {
console.log(p);
}


//0f2b69f21be3a050d22899bc1d4bcb6c = Cloud Intake - Non/Pre Production
//ae576bd3db6c74d0b5e3c45813961978 = Cloud Intake - Production
//b151e0e41b447010d22899bc1d4bcbd2 = Cloud Intake Workflow (CIW)
//09b0e425db43f81046519b6ed3961927 = Cloud - CaaS Prod - Design & Account Provisioning Flow
//60a3ed8197b1d9106642bd8c1253af55 = Central Intake - CaaS - New LDAP Group Request
var wfc = new GlideRecord('wf_context');
wfc.addQuery('id', 'IN', intake_accs);
wfc.addEncodedQuery('');
if (!isCIRv2) {
wfc.addQuery('workflow', 'b151e0e41b447010d22899bc1d4bcbd2').addOrCondition('workflow', 'ae576bd3db6c74d0b5e3c45813961978').addOrCondition('workflow', '0f2b69f21be3a050d22899bc1d4bcb6c').addOrCondition('workflow', '09b0e425db43f81046519b6ed3961927').addOrCondition('workflow', '60a3ed8197b1d9106642bd8c1253af55');
} else {
wfc.addQuery('workflow', '0ed0bf504761e11026b297a8036d4399').addOrCondition('workflow', '47f0bb144761e11026b297a8036d43df').addOrCondition('workflow', '94f3ffd44761e11026b297a8036d4308').addOrCondition('workflow', '921437184761e11026b297a8036d4311').addOrCondition('workflow', 'fc43f9cb978ee950744f71c71153af97').addOrCondition('workflow', 'ef053b584761e11026b297a8036d435e').addOrCondition('workflow', '7d20917847a1651026b297a8036d4395').addOrCondition('workflow', 'f0c7c9a84721e110141de6ce536d432e').addOrCondition('workflow', 'db11b9304765651026b297a8036d43ae').addOrCondition('workflow', 'fc43f9cb978ee950744f71c71153af97').addOrCondition('workflow', '60a3ed8197b1d9106642bd8c1253af55').addOrCondition('workflow', 'f58be60f87c912100af333773cbb3584').addOrCondition('workflow', 'cdcee8e047eda110141de6ce536d4325').addOrCondition('workflow', '420e6ca047eda110141de6ce536d43fc').addOrCondition('workflow', '2112f8a447eda110141de6ce536d4316').addOrCondition('workflow', '6d9f242447eda110141de6ce536d43e1').addOrCondition('workflow', 'ef053b584761e11026b297a8036d435e');
}
wfc.query();

while (wfc.next()) {
var wfcObj = {};
wfcObj.relatedRecord = wfc.getDisplayValue('id');
var related_Record = wfcObj.relatedRecord;
wfcObj.started = wfc.started.toString();

if (related_Record && related_Record.indexOf("Cloud Account Request") !== -1) {
var cloudAccount_sysid = wfc.getValue("id");
var cloudAccount_env;
var cloudAccount = new GlideRecord("u_cloud_intake");
cloudAccount.addQuery("sys_id", cloudAccount_sysid);
cloudAccount.query();
if (cloudAccount.next()) {
cloudAccount_env = cloudAccount.getDisplayValue("u_environment");
}
wfcObj.relatedRecord = related_Record + " - " + cloudAccount_env;
}
wfcObj.currentActivities = [];
var wfe = new GlideRecord('wf_executing');
wfe.addQuery('context', wfc.getUniqueValue());
wfe.query();
while (wfe.next()) {
if (hideIds.indexOf(wfe.activity.name.getDisplayValue()) >= 0) continue;
if (wfe.activity.activity_definition.getDisplayValue() == 'Join') continue;
var wfeObj = {};
var wfeObj1 = {};
wfeObj1.strName = 'Pending tasks : ';
wfeObj.name = wfe.activity.name.getDisplayValue();
wfeObj.definition = wfe.activity.activity_definition.getDisplayValue();
//Production rediness checklist
if ((wfeObj.name == "Application Security Production Readiness checklist") || (wfeObj.name == "Data Protection Production Readiness Checklist") || (wfeObj.name == "Enterprise Cloud Governance Production Readiness checklist") || (wfeObj.name == "Disaster Recovery Production Readiness checklist") || (wfeObj.name == "Privacy Production Readiness checklist")) {


var scratchpad_task = wfe.scratchpad.getValue();
var scratchpadObject_task = JSON.parse(scratchpad_task);
var sysid_task = scratchpadObject_task.taskID;


var cloudTask = new GlideRecord("u_cloud_intake_task");
cloudTask.addQuery("sys_id", sysid_task);
cloudTask.query();
if (cloudTask.next()) {
var assignment_group = cloudTask.assignment_group.getDisplayValue();
var escalationContact = cloudTask.assignment_group.manager.getDisplayValue();
var assigned_to = cloudTask.assigned_to.getDisplayValue();
}
if (assignment_group && assigned_to) {
wfeObj.name = wfeObj.name + " - " + assignment_group + " - " + assigned_to + " - " + "Escalation contact is " + escalationContact;
} else if (assignment_group && (assigned_to == "")) {
wfeObj.name = wfeObj.name + " - " + assignment_group + " - " + "Escalation contact is " + escalationContact;
} else if ((assignment_group == "") && assigned_to) {
wfeObj.name = wfeObj.name + " - " + assigned_to;
} else {
wfeObj.name = wfeObj.name;
}

Thank you.

0 REPLIES 0