- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2022 06:18 PM
Hello,
I have am having trouble when I test my script. I dont think my array is working or in the right location.
I want to push all the servers im getting into an array.
var user = gs.getUserID();
var arr = [];
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2022 07:39 PM
Hello
On first look, your script seems fine to me.
But what might be causing the undefined error could be in the below lines:
application_name: servers.name.toString(),
app_code: servers.u_app_code.toString(),
application_criticality: servers.business_criticality.toString(),
ritm_number: servers.sc_item_option.number.sc_req_item.toString(),
dateTime: servers.opened_at.toString(),
due_Date: servers.sc_item_option.number.sc_req_item.due_date.toString()
if the value of servers.name is empty, server.name.toString() would return an Undefined error.
Likewise if the value of servers.u_app_code is empty, servers.u_app_code.toString() would return an Undefined error.
try replacing the above code block with the below:
application_name: servers.name.toString() || '',
app_code: servers.u_app_code.toString() || '',
application_criticality: servers.business_criticality.toString() || '',
ritm_number: servers.sc_item_option.number.sc_req_item.toString() || '',
dateTime: servers.opened_at.toString() || '',
due_Date: servers.sc_item_option.number.sc_req_item.due_date.toString() || ''

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2022 07:39 PM
Hello
On first look, your script seems fine to me.
But what might be causing the undefined error could be in the below lines:
application_name: servers.name.toString(),
app_code: servers.u_app_code.toString(),
application_criticality: servers.business_criticality.toString(),
ritm_number: servers.sc_item_option.number.sc_req_item.toString(),
dateTime: servers.opened_at.toString(),
due_Date: servers.sc_item_option.number.sc_req_item.due_date.toString()
if the value of servers.name is empty, server.name.toString() would return an Undefined error.
Likewise if the value of servers.u_app_code is empty, servers.u_app_code.toString() would return an Undefined error.
try replacing the above code block with the below:
application_name: servers.name.toString() || '',
app_code: servers.u_app_code.toString() || '',
application_criticality: servers.business_criticality.toString() || '',
ritm_number: servers.sc_item_option.number.sc_req_item.toString() || '',
dateTime: servers.opened_at.toString() || '',
due_Date: servers.sc_item_option.number.sc_req_item.due_date.toString() || ''