- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2023 01:55 PM
Two-part question. I'm creating an action in flow designer that takes input from two different Lookup Records actions. The Lookup Records action says it outputs an array of sys ids. I set the input data type for the action to Records.correspondingtable When I tried to add an array of sys ids to test the action, it treated the whole input like a string and iterated through each character. I'm also outputting an array of objects but the flow test says the variable output is undefined.
- What test input can I use for the action to emulate the lookup records output?
- Is the Array.Object data type expecting a certain format for the object or just a general javascript object data type?
(function execute(inputs, outputs) {
var recs = inputs.cases;
var ents = inputs.entitlements;
var acct = inputs.account;
var entCals = [];
var eUtil = new EntitlementCalcActionUtil();
gs.info("[Entitlements Calculation Flow Action]: variables\nRecords: " + recs + "\nEntitlements " + ents + " " + ents.length);
for (var i = 0; i < ents.length; i++) {
var grEnts = new GlideRecord('service_entitlement');
grEnts.addQuery("sys_id", ents[i]);
/* if (acct) {
grEnts.addQuery('account',acct);
} */
grEnts.query();
gs.info("[Entitlements Calculation Flow Action]: ents[i] value: " + ents[i]);
if (grEnts.next()) {
gs.info("[Entitlements Calculation Flow Action]: Entitlement record found - " + grEnts.entitlement_name);
var actionObj = {
entName: {
"Account": grEnts.account,
"Salesforce Customer Number": grEnts.account.u_salesforce_customer_number,
"Salesforce Contract Number": "",
"Name": grEnts.entitlement_name,
"Billing Increment": grEnts.u_billing_increments,
"Billing Minimum": grEnts.u_billing_increments_minimum,
"Total Units": grEnts.total_units,
"Price Per Hour": grEnts.u_price_per_hour,
"Total Consumed Units": 0,
"Remaining Units": 0,
"Overage Units": 0,
"Additional Price per Hour": grEnts.u_additional_price_per_hour,
"Billing Total": 0,
"Process Check": false
}
};
var keyName = "EntCount" + (i + 1);
gs.info("[Entitlements Calculation Flow Action]: Entitlement count " + keyName);
actionObj[keyName] = actionObj["entName"];
delete actionObj["entName"];
//get variables for calculation from entitlement found
//MAY HAVE TO USE METRIC TO GET HISTORICAL DATA FROM ENTITLEMENTS. THIS CONFIGURATION WOULD USE CURRENT ENTITLEMENT DATA
for (var j = 0; j < recs.length; j++) {
var grCases = new GlideRecord('sn_customerservice_case');
grCases.get(recs[j]);
grCases.addQuery('account', grEnts.account);
grCases.setLimit(1);
grCases.query();
if (grCases.next()) {
eUtil.entitlementCalc(grEnts, grCases, actionObj, keyName);
//use script include to plug in entitlements variables and case time worked
}
}
gs.info("[Entitlements Calculation Flow Action]: Entitlement Object pushed: " + Object.keys(actionObj[keyName]));
entCals.push(actionObj);
}
};
gs.info("[Entitlements Calculation Flow Action]: Final output variable value: " + entCals[0]["EntCount1"] + "\n" + Object.keys(entCals[0]) + "\nLength - " + entCals.length);
outputs.report_entitlements = entCals
return outputs.report_entitlements;
})(inputs, outputs);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 09:33 AM
I found a video that helped in building the variables for the input and output. I also wasn't treating the array like glide records so that helped in simplifying my script. I'm still not sure what kind if input to use to test the action but it's working better now. Just some tweaking left. Hopefully this helps someone else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2023 03:27 PM
I was able to get the output variable updated but now the action is throwing an internal server error. It seems like the the input of records is not just an array of sys ids but an array of glide records. I'll have to update the action and revisit this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2023 09:33 AM
I found a video that helped in building the variables for the input and output. I also wasn't treating the array like glide records so that helped in simplifying my script. I'm still not sure what kind if input to use to test the action but it's working better now. Just some tweaking left. Hopefully this helps someone else.
