- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:42 AM
While saving the catalog item client script, it give me an error
Line no :-23 arr.push(data[i].name1.toString().replace(/\s/g, "") ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:48 AM
like i said i gave a sample code, obviously typos were expected.
share your full code for me to look upon
also that i made some edit to the original ,please note
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:50 AM
Full code:-
function onSubmit() {
var arr=[];
var loc=g_form.getValue('create_new_sites');// Internal name of multiline variable set
if(loc == '[]' ){
g_form.addErrorMessage('You must enter at least 1 row');
return false;
}
var data = JSON.parse(loc);
var ct= 0;
for(var i in data){
if (data.hasOwnProperty(i)) {
arr.push(data[i].name1.toString().replace(/\s/g, "") ;
}
ct=ct+1;
}
function removeDuplicate(arr) {
var c;
var len = arr.length;
var result = [];
var obj = {};
for (c = 0; c<len; c++) {
obj[arr[c]] = 0;
}
for (c in obj) {
result.push(c);
}
return result;
}
if(removeDuplicate(myArr).length>0){
g_form.addErrorMessage('Duplicate value present');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:52 AM
function onSubmit() {
var arr=[];
var loc=g_form.getValue('create_new_sites');// Internal name of multiline variable set
if(loc == '[]' ){
g_form.addErrorMessage('You must enter at least 1 row');
return false;
}
var data = JSON.parse(loc);
var ct= 0;
for(var i in data){
if (data.hasOwnProperty(i)) {
arr.push(data[i].name1.toString().replace(/\s/g, "")) ; //added a ) here
}
ct=ct+1;
}
function removeDuplicate(arr) {
var c;
var len = arr.length;
var result = [];
var obj = {};
for (c = 0; c<len; c++) {
obj[arr[c]] = 0;
}
for (c in obj) {
result.push(c);
}
return result;
}
if(removeDuplicate(myArr).length>0){
g_form.addErrorMessage('Duplicate value present');
return false;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:55 AM
mark correct if this works for you