Getting error as "Undefined value has no properties"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 11:40 PM
Hello ,
i am trying to pass the JSON to remote change system .
For this we have used flow designer with integration hub .
we are trying to pass the payload with script include ...
when i am testing the action in flow designer i am getting the error as undefine value has no property
Can you please help me where exactly i am going wrong in the script.
var ChangeScriptInclude = Class.create();
ChangeScriptInclude.prototype = {
initialize: function() {},
createChangePayload: function(change_sys_id) {
var changeSysId = change_sys_id;
gs.info('test in prog' + changeSysId);
var changeRec = new GlideRecord('change_request');
var note = changeRec.work_note.getJournalEntry(1);
var v1 = "";
var appr = new GlideRecord('sysapproval_approver');
appr.addQuery('sysapproval', changeSysId);
appr.query();
gs.info(appr.getRowCount());
if (appr.next())
{
v1 = appr.state.toString();
gs.info('into loop' + v1);
}
t1 = "";
t2 = "";
var task = new GlideRecord('change_task');
task.addQuery('number', changeSysId);
if (task.next()) {
t1 = task.state;
}
var changeValues = {};
// changeRec.addQuery('sys_id', changeSysId);
// changeRec.query();
// if (changeRec.next()) {
// var num = changeRec.number;
// gs.addInfoMessage("test" + num);
changeValues.id = changeRec.getDisplayValue('number'), // PMI CHG Number
//"requestType": "changeRec.getValue('type')", // Standard, Normal or Emergency
changeValues.status=changeRec.getValue('state');// 2 for In Progress, -5 for Registred or 3 for Closed
gs.info("into loop1" + v1);
gs.info("comments" + v2);
changeValues.characteristic = [{
"name": "Source System",
"value": "PMI" // Fixed Value
},
{
"name": "Stage",
"value": changeRec.getValue('u_stage') // implement, approve, analyze or verify_and_closevar
},
{
"name": "Customer Confirmation",
"value": v1 //approval result on the change request
},
{
"name": "Customer Confirmation explanation",
"value": note // comments on the approval record
},
{
"name": "Close Code",
"value": t1 // Closed Completed ( if Review Task is completed), Closed Incompleted (if Review Task is Incompleted), Closed Cancelled, Closed Rollback
},
{
"name": "Close Note",
"value": note // The comment that is added on the review task.
}
];
return changeValues;
},
type: 'ChangeScriptInclude'
};
Regards,
Rutuja
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2021 02:53 AM
Hi Ankur,
calling the script include in create payload stepp of an custom action
(function execute(inputs, outputs) {
var plBuilder = new sn_ebonding_ah.ChangeScriptInclude();
gs.info('test' +plBuilder);
var payload = plBuilder.createChangePayload(inputs.change_sys_id);
outputs.rest_body = JSON.stringify(payload);
})(inputs, outputs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2021 03:05 AM
Hi,
So are you sure the script include function is getting called?
Is your flow and the script include in same scope?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2021 03:07 AM
HI Ankur,
yes its in the same scope
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2021 03:37 AM
then it should get called
Did you add gs.info() at the start of the script include to check if it is getting called or not
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader