
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 11:46 AM
Hello everyone,
I'm getting SyntaxError: Unexpected end of JSON input on the below client script. I'm filtering the asset MRVS by multiple locations, and trying to a tell the user they can't add more than 50 records to the MRVS. The onScript works okay but gives me that error when the first location is added. I'm guessing because when the location is added the MRVS doesn't have anything filled in so it's throwing up that error.
Is there anyway around this?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var MRVS = JSON.parse(g_form.getValue('my_managed_assets'));
var MRVSlength = MRVS.length;
if (MRVSlength > 5) {
g_form.addErrorMessage("You can not submit more than 50 assets with this form. Please remove a filter location or assets.");
}
}
'
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 12:38 PM
If you get the value first and then do the parse, does it make a difference?
var mrvsValue = g_form.getValue('my_managed_assets');
var MRVS = JSON.parse(mrvsValue);
g_form.addInfoMessage(MRVS);
var MRVSlength = MRVS.length;
g_form.addInfoMessage(MMRVSlength);
If you run the code below, what is displayed?
var mrvsValue = g_form.getValue('my_managed_assets');
var MRVS = JSON.stringify(mrvsValue);
g_form.addInfoMessage(MRVS);
//var MRVSlength = MRVS.length;
//g_form.addInfoMessage(MMRVSlength);
MVP 2025 ✨
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 11:53 AM
If you write a g_form.addInfoMessage(MRVS) log what is displayed?
MVP 2025 ✨

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 12:26 PM
This is what it's showing:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var MRVS = JSON.parse(g_form.getValue('my_managed_assets'));
var MRVSlength = MRVS.length;
g_form.addInfoMessage(MRVS);
/*
if (MRVSlength > 5) {
g_form.addErrorMessage("You can not submit more than 50 assets with this form. Please remove a filter location or assets.");
}
}
*/
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 12:38 PM
If you get the value first and then do the parse, does it make a difference?
var mrvsValue = g_form.getValue('my_managed_assets');
var MRVS = JSON.parse(mrvsValue);
g_form.addInfoMessage(MRVS);
var MRVSlength = MRVS.length;
g_form.addInfoMessage(MMRVSlength);
If you run the code below, what is displayed?
var mrvsValue = g_form.getValue('my_managed_assets');
var MRVS = JSON.stringify(mrvsValue);
g_form.addInfoMessage(MRVS);
//var MRVSlength = MRVS.length;
//g_form.addInfoMessage(MMRVSlength);
MVP 2025 ✨

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2021 12:58 PM
I'm not seeing any errors on either one, but also no info logs that I can see