I'm creating a Flow Action that will update the fields as well as the work notes based on the selected options from a catalogue item.
(function execute(inputs, outputs) {
try {
// Optional: initialise outputs to safe defaults
outputs.process_successful = false;
outputs.process_message = '';
var anyUpdate = false;
// Get business application record
var grRecord = new GlideRecord('cmdb_ci_business_app');
if (!grRecord.get(inputs.strAppSysID)) {
outputs.process_successful = false;
outputs.process_message = 'Record not found for sys_id: ' + inputs.strAppSysID;
return;
}
// Only update the values that were selected
if (inputs.blnUpdateBusinessOwner) {
grRecord.u_business_owner = inputs.strBusinessOwner; // sys_id for reference
anyUpdate = true;
}
if (inputs.blnUpdateBusinessOwnerRepresentative) {
grRecord.u_business_owner_representative = inputs.strBusinessOwnerRepresentative; // sys_id
anyUpdate = true;
}
if (inputs.blnUpdateTechnicalOwner) {
grRecord.u_custodian = inputs.strTechnicalOwner; // sys_id
anyUpdate = true;
}
if (inputs.blnUpdateTechnicalOwnerRepresentative) {
grRecord.u_cmdb_data_steward = inputs.strTechnicalOwnerRepresentative; // sys_id
anyUpdate = true;
}
if (inputs.blnUpdateBusinessOwningPlatformLab) {
grRecord.u_business_owning_business_unit = inputs.strBusinessOwningBusinessUnitFunction; // ref/sys_id
grRecord.u_business_owning_division = inputs.strBusinessOwningPlatform; // ref/sys_id
if (inputs.strBusinessOwningLab) {
grRecord.department = inputs.strBusinessOwningLab; // sys_id
} else {
grRecord.department = inputs.strBusinessOwningPlatform; // sys_id fallback
}
anyUpdate = true;
}
if (inputs.blnUpdateTechnicalOwningPlatformLab) {
grRecord.u_accountable_it_division = inputs.strTechnicalOwningPlatform; // ref/sys_id
grRecord.u_accountable_it_business_unit = inputs.strTechnicalOwningBusinessUnitFunction; // ref/sys_id
if (inputs.strTechnicalOwningLab) {
grRecord.u_accountable_it_organisation = inputs.strTechnicalOwningLab; // ref/sys_id
grRecord.u_accountable_it_team = inputs.strTechnicalOwningLab; // ref/sys_id
} else {
grRecord.u_accountable_it_organisation = inputs.strTechnicalOwningPlatform; // ref/sys_id
// leave team untouched if not provided
}
anyUpdate = true;
}
if (!anyUpdate) {
outputs.process_successful = true;
outputs.process_message = 'No Ownership fields were selected for update.';
return;
}
// Update the record without running business rules/workflows
grRecord.setWorkflow(false);
grRecord.update();
// Initialise the audit string BEFORE concatenation
var strWorknoteAudit = '';
// Business ownership section
if (inputs.blnUpdateBusinessOwner || inputs.blnUpdateBusinessOwnerRepresentative || inputs.blnUpdateBusinessOwningPlatformLab) {
strWorknoteAudit += 'The following Business Ownership fields were updated:\n';
}
if (inputs.blnUpdateBusinessOwner) {
strWorknoteAudit += '- Business Owner: ' + grRecord.u_business_owner.getDisplayValue() + '\n';
}
if (inputs.blnUpdateBusinessOwnerRepresentative) {
strWorknoteAudit += '- Business Owner Representative: ' + grRecord.u_business_owner_representative.getDisplayValue() + '\n';
}
if (inputs.blnUpdateBusinessOwningPlatformLab) {
strWorknoteAudit += '- Business Owning Organisation: ' + grRecord.department.getDisplayValue() + '\n';
strWorknoteAudit += '- Business Owning BU: ' + grRecord.u_business_owning_business_unit.getDisplayValue() + '\n';
strWorknoteAudit += '- Business Owning Platform: ' + grRecord.u_business_owning_division.getDisplayValue() + '\n';
}
// Technical ownership section
if (inputs.blnUpdateTechnicalOwner || inputs.blnUpdateTechnicalOwnerRepresentative || inputs.blnUpdateTechnicalOwningPlatformLab) {
// Add a separating newline only if something already exists
if (strWorknoteAudit) strWorknoteAudit += '\n';
strWorknoteAudit += 'The following Technical Ownership fields were updated:\n';
}
if (inputs.blnUpdateTechnicalOwner) {
strWorknoteAudit += '- Technical Owner: ' + grRecord.u_custodian.getDisplayValue() + '\n';
}
if (inputs.blnUpdateTechnicalOwnerRepresentative) {
strWorknoteAudit += '- Technical Owner Representative: ' + grRecord.u_cmdb_data_steward.getDisplayValue() + '\n';
}
if (inputs.blnUpdateTechnicalOwningPlatformLab) {
strWorknoteAudit += '- Accountable Tech Organisation: ' + grRecord.u_accountable_it_organisation.getDisplayValue() + '\n';
strWorknoteAudit += '- Accountable Tech BU: ' + grRecord.u_accountable_it_business_unit.getDisplayValue() + '\n';
strWorknoteAudit += '- Accountable Tech Platform: ' + grRecord.u_accountable_it_division.getDisplayValue() + '\n';
strWorknoteAudit += '- Accountable Tech Team: ' + grRecord.u_accountable_it_team.getDisplayValue() + '\n';
}
// Finalise outputs
outputs.process_successful = true;
outputs.process_message = strWorknoteAudit || 'Updates applied, but no audit details were generated.';
} catch (myError) {
var msg = (myError && myError.message) ? myError.message : (myError + '');
outputs.process_successful = false;
outputs.process_message = 'Record update failed with error: ' + msg;
}
})(inputs, outputs);
I'm calling my action via a subflow:

Both of these Actions will update some fields and work notes on a business application. However, what I've noticed is that it will update the work notes from the first Action, but not the second one. When I check the flow context for my second Action, the results appear correctly in the process_message:

I've defined my outputs within my script:


So I'm not too sure why I can't see anything in the work notes of a business application.