Unable to populate Change fields when creating a Change from a Service Request using Deluge

Unable to populate Change fields when creating a Change from a Service Request using Deluge

Using sample Custom Function sample code as a base. Code creates a Change Ticket with the Title and Description fields populated. No other fields populate. For testing, I used a clean "Normal Change Template (default)", I cleared all fields and removed mandatory settings. I created a clean Service Request template and removed mandatory fields. When saving and testing the Deluge Code, I used the info command and confirmed the code was retrieving the information from the Service Request. As you can see in the JSON string, I removed the additional fields trying to make the string as simple as possible.  Here is the code, and screen shots of the Change Ticket and Service Request:

//Assigning value got from the Request fields to variables.These values can be used in constructing the JSON for creating the Change
requestID = requestObj.get("id");
createdTime = requestObj.get("created_time");
ReqSubject=requestObj.get("subject");
ReqDescription=requestObj.get("description");
ReqCategory=requestObj.get("Category");
ReqSubcategory=requestObj.get("subcategory");
ReqItem=requestObj.get("item");
ReqChangeOwner=requestObj.get("changeowner");
//ReqApplication=requestObj.get("udf_fields").get("udf_pick_27");
ReqScheduledstarttime=requestObj.get("scheduled_start_time");
ReqScheduledendtime=requestObj.get("scheduled_end_time");

//info requestObj.get("udf_fields").get("udf_pick_27");
info requestObj.get("scheduled_start_time");
info requestObj.get("scheduled_end_time");


//{"template":{"name":"1 Standard - Schedule Vendor Changes","id": "1503"},
//,"scheduled_start_time":ReqScheduledstarttime.get("display_value"),"scheduled_end_time": ReqScheduledendtime.get("display_value")
//inputData = {"operation":{"details":{"template":{"name":"1 Standard - Schedule Vendor Changes","id": "1503"}}}};
// "udf_fields":{"fields":{"udf_pick_601":ReqApplication}},
//,"scheduled_start_time":ReqScheduledstarttime.get("value"),"scheduled_end_time": ReqScheduledendtime.get("value")

inputData = {"operation":{"details":{"title":"[RE-"+requestID+"] "+ReqSubject,"description":ReqDescription,"stagename": "planning","statusname": "Requested For Information","priority":"high"}}};

instanceJson = context.get("instance");
helpdeskID = instanceJson.get("id");

// url: "http://sgb-bsd:8080/api/v3/changes"
response = invokeurl
[
url: "http://Server:xxxx/sdpapi/change"
type: POST
parameters: {"INPUT_DATA":inputData,"TECHNICIAN_KEY":"xxxxxxxxxxx-xxxxxx-xxxx-xxxxxxxxx","format":"json","OPERATION_NAME":"ADD","PORTALID":helpdeskID}
];
info response;
operation = response.get("operation");
result = operation.get("result");
status = result.get("status");

//Messages to be printed in Request history
returnObj = Collection();
if("success".equalsIgnoreCase(result.get("status"))) {
returnObj.insert("result":"success");
returnObj.insert("message":"Change request created successfully");
} else {
returnObj.insert("result":"failure");
returnObj.insert("message":"Problem in creating change request");
}
return returnObj;





                  New to ADSelfService Plus?