throw error if value already present in table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:07 AM
Hi Team,
On Portal we have populate the value Name and the value of name is stored in "site using" table.
Requirement is to check if value of name already present in site using table, throw an error and RITM not created.
We can add multiple value by clicking on add and need to check all the values.
Note:- This all variables came under multi line variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:32 AM
Hi,
This cannot be done through onchange script but can be done using onsubmit script.
Example script:
function onSubmit() {
var arr=[];
var loc=g_form.getValue('name_of_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].<field_name>.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;
}
}
Warning:
This is a just an example script written on the go,please test it before deploying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:36 AM
Where can i write this?
In the multiline variable set client script or catalog item client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:39 AM
on the catalog item client script
- 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, "") ;