Populating MRVS using cartJS, optional field shows null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2024 08:24 AM
I am trying to trigger/submit a catalog item (with MRVS) using cartJS. The mandatory fields are being populated correctly but the optional fields are being populated as "null". I would like to display it as Empty String.
I tried setting the variable as
source_nat': ''
but still it shows "null"
I am using the code below.
var createRow = {
'config_division': '' + division,
'application_name': '' + appName,
'source_nat': '',
'm_application_name': '',
'config_action': 'Add',
};
mrvs.push(createRow);
var strMrvsData = JSON.stringify(mrvs);
var cart = new sn_sc.CartJS();
var item = {
'sysparm_id': '687c8d571b196c98221b0fa5624bcb92',
'sysparm_quantity': '1',
'variables': {
'requestor': '' + requestor,
'connect_sr_firewallconfig': '' + strMrvsData //MRVS
}
};
var cartDetails = cart.addToCart(item);
var checkoutInfo = cart.checkoutCart();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 11:05 AM
@scorpion Please refer the below link for the similar method,
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2024 09:58 AM
Hi @Sujatha V M
Thanks for referring to the article but it doesn't solve the issue.
I have 10 variable in MRVS, only 3 of them are mandatory, rest 7 variables are optional. So when i am creating the MRVS I am not supplying values to those 7 optional Variables.
When i submit the Catalog using cartJS, those 7 variables shows up as "null", Which i don't want, Is there any way those variable values show up as an empty string (nothing) and not null on the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2024 12:25 AM - edited 05-07-2024 12:26 AM
Can you please share some screenshots of the complete variables that shows "Null" values because in your screenshot, I can see two entries on the same column.
Also, what's the variable type being used?
I tried the above script and it worked without any issues in my PDI.
Please mark this as helpful and accept it as a solution if this resolves your query.
Thanks,
Sujatha V.M.
Sujatha V.M.