Dotwalk using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 05:18 AM
I want to Dotwalk value in Account table and need to assign that value to a field. Currently the value is not coming
I tried to map the field like u_account_manager:responseObj[i].account.u_account_manager in the
below script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2024 05:52 AM
Hi @Kri - Did you try adding a gs.info() to inspect the response object?
for (var i = 0, len = responseObj.length; i < len; ++i) {
gs.info("Inspecting response object: " + JSON.stringify(responseObj[i])); // Debug the full object
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 04:28 PM
Its returning 'undefined' as a result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2024 04:42 PM
Try something like this instead (the goal is to check the full response body, and verify the result property exists and is an array):
var requestBody = {};
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setAuthenticationProfile('basic', '0d2c8ab61b823d1079bafdd91d4bcb1b'); // sys_auth_profile_basic record
restMessage.setHttpMethod("get");
restMessage.setEndpoint(baseURL + "/api/now/table/x_security_case?");
restMessage.setQueryParameter("sysparm_query", "sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()");
restMessage.setQueryParameter("sysparm_limit", "100");
restMessage.setQueryParameter("sysparm_display_value", "true");
restMessage.setRequestBody(JSON.stringify(requestBody));
var response = restMessage.execute();
var responseBody = response.getBody();
gs.info("Response Body: " + responseBody);
gs.info("Response Object: " + JSON.stringify(responseObj));
var responseObj = JSON.parse(responseBody).result;
for (var i = 0, len = responseObj.length; i < len; ++i) {
if (!responseObj[i]) {
gs.info("Undefined item at index: " + i);
continue;
}
gs.info("Processing: " + JSON.stringify(responseObj[i]));
/*
v_table.addRow({
sys_id: responseObj[i].sys_id,
u_account_manager: responseObj[i].account.u_account_manager
});
*/
}