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-27-2021 11:44 PM
Try making script include client callable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 11:47 PM
Hi,
did you add gs.info() statements and check for debugging
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
‎03-30-2022 10:51 AM
Hi Ankur,
can you expand on the question of adding gs.info() statements? I too am getting a similar error:
com.glide.script.RhinoEcmaError: The undefined value has no properties.
sys_ui_action.4fdad0f11b6e8d50e78fa603604bcb10.script : Line(5) column(0)
2: gs.info("<BP> - get_cot: Testing Logging");
3:
4: var si = global.cpx_refund_util();
==> 5: si.test();
6:
7: action.setRedirectURL(current);
I am trying to work around a UI action and Script include that is causing me problems and I know it's likely something small I've either added in error or left out.
UI Action:
gs.addInfoMessage("You Pressed the Get COT button!");
gs.info("<BP> - get_cot: Testing Logging");
var si = global.cpx_refund_util();
si.test();
action.setRedirectURL(current);
Script Include:
var cpx_refund_util = Class.create();
cpx_refund_util.prototype = {
initialize: function() {
},
test: function(){ //test function to verify and degug code that calls this Script Include
gs.info("<BP> cpx_refund_automationutils: Successfully reached test function");
gs.addInfoMessage(gs.getMessage("Successfully reached test function"));
return;
},
type: 'cpx_refund_util'
};
I should be getting the gs.info message in the log but I am not all I get is the error.
I was right.... something small I missed and continued to overlook.
solution:
var si = new global.scriptinclud();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2021 11:49 PM
Hi,
Are you passing the correct sys_id?
Also try this
return JSON.stringify(changeValues);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader