Workflow run script returning undefined value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 11:35 PM - edited 02-20-2024 02:36 AM
Hi,
I'm working on a workflow. On my Case form there is a field called 'JSON Output'. I'm trying to get it into workflow by using run script. However its returning empty. Can anyone help where I'm wrong.
Run Script:
var CaseRec = new GlideRecord('sn_customerservice_case');
CaseRec.addQuery('number', current.number);
CaseRec.query();
if (CaseRec.next()) {
workflow.info("rec found");
var JsonOutput = CaseRec.getValue('u_json_output');
workflow.scratchpad.jsonObject = JSON.parse(JsonOutput);
workflow.info("json check" + workflow.scratchpad.jsonObject);
}
After this run script, there is an if condition. From that I'm getting the below error
Error:
org.mozilla.javascript.WrappedException: Wrapped TypeError: Cannot read property "u_supply_planner_field_1" from undefined (// This script needs to set answer to 'yes' or 'no' to indicate the state of the activity.
//
// For example,
//
answer = ifScript();
function ifScript() {
if (workflow.scratchpad.jsonObject.u_supply_planner_field_1.changed_value) {
return 'yes';
} else {
return 'no';
}
}; line 8 )(sys_script_include.365eca63c0a8016600069528aee5affb.script; line 117)
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 03:56 AM
Hi Aruna,
This will be difficult to troubleshoot without fully seeing each piece of this. However your error message is having a problem with the customer field "u_supply_planner_field_1".
Are we 100% certain that by the time this step of your workflow runs, that there is a value in this field on the current item triggering the workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2024 04:22 AM
Hi @Aruna Sree Yela ,
What out are you getting in this?
workflow.info("json check" + workflow.scratchpad.jsonObject);
Also can u paste the value stored in
u_json_output
Thanks,
Danish