- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 06:09 AM
I have a multi row variable set which has some variables. Here for one of the variables the user is not entering any value. And the error is coming as cannot convert null to object
The error is coming as
I also tried to add code as
if(advance_attribute_sample_json ==null)
advance_attribute_sample_json == " ";
Still the same error was coming.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 12:25 PM
Hi @shalikasurbhi1
check the below code:
(function execute(inputs, outputs) {
// Parse the resource_list from inputs
var inp = JSON.parse(JSON.stringify(inputs.resource_list));
var mvrs = JSON.stringify(inp);
var rowCount = inp.length;
// Iterate through each row
for (var i = 0; i < rowCount; i++) {
var row = inp[i];
gs.log("mvrs 3" + JSON.stringify(row));
// Assign default values if the variable is null or undefined
var resource_no = row.resource_no || '';
var count = row.count || 0;
var resource_target_platform = row.resource_target_platform || '';
var resource_location_mrvs = row.resource_location_mrvs || '';
var resource_type = row.resource_type || '';
var resource_subtype = row.resource_subtype || '';
var resource_sku = row.resource_sku || '';
var price_month = row.price_month || 0;
var cost = row.cost || 0;
var advance_attribute_sample_json = row.advance_attribute_sample_json || {};
// Proceed with your logic using these variables
}
})(inputs, outputs);
……………………………………………………………………………………………………
Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 12:25 PM
Hi @shalikasurbhi1
check the below code:
(function execute(inputs, outputs) {
// Parse the resource_list from inputs
var inp = JSON.parse(JSON.stringify(inputs.resource_list));
var mvrs = JSON.stringify(inp);
var rowCount = inp.length;
// Iterate through each row
for (var i = 0; i < rowCount; i++) {
var row = inp[i];
gs.log("mvrs 3" + JSON.stringify(row));
// Assign default values if the variable is null or undefined
var resource_no = row.resource_no || '';
var count = row.count || 0;
var resource_target_platform = row.resource_target_platform || '';
var resource_location_mrvs = row.resource_location_mrvs || '';
var resource_type = row.resource_type || '';
var resource_subtype = row.resource_subtype || '';
var resource_sku = row.resource_sku || '';
var price_month = row.price_month || 0;
var cost = row.cost || 0;
var advance_attribute_sample_json = row.advance_attribute_sample_json || {};
// Proceed with your logic using these variables
}
})(inputs, outputs);
……………………………………………………………………………………………………
Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 01:19 AM
Still the same error is coming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2024 01:35 AM
Also when i raised another request where I filled all the variables still the same error was coming
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 05:29 PM
resource_list seems to be a string so
var inp = JSON.parse(JSON.stringify(inputs.resource_list));
should really be:
var inp = JSON.parse(inputs.resource_list);
As a side note, variable mvrs is not used, so
var mvrs =JSON.stringify(inp);
should be removed.