The CreatorCon Call for Content is officially open! Get started here.

Getting error as "Undefined value has no properties"

rutuja7
Kilo Contributor

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'

};

 

@Ankur Bawiskar could you please help me 

 

Regards,

Rutuja

13 REPLIES 13

yepp i am pasing the correct change sys id 

 

rutuja7
Kilo Contributor

tried with json.strigify but same issue

Hi,

did you add logs and check what came in gs.info(JSON.stringify(changeValues));

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

NO ankur i m not getting log for change values

it means the script include is not getting called.

Can you share how and from where you are calling the script include

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader