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-07-2019 12:46 AM
Add the similar line of code into another array(because its simpler),and in the same for loop,add another glideajax parameter.
Use the second parameter in your script include and return true false accordingly.
However, since it was not mentioned in the original question could you please take it up in another post, and complete this post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2019 12:55 AM
Issue not resolved yet. When i added the above line of code, request submitted without thrrwoing an error message.
I selected the same value which already present in the table.
and please modified the code with the above new req

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:34 AM
Write a onchange Catalog Client script on name field and call a script include.
The SI shall take the newValue and look into the site table and return true/false depending on value exist or not.
If value exist, throw an error.
This way, you can restrict creation of item in the add form itself.
Mark the comment as a correct answer and also helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:36 AM
I need this validation on submit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 03:47 AM
Hi Asif,
I created a script include
var siteDetails = Class.create();
siteDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
sitecheck: function(){
var ans= 'false';
var gr=new GlideRecord('u_cmdb_ci_sites_using');
gr.addQuery("name",this.getParameter('sysparam_id'));
gr.query();
gr.next();
if(gr.next())
{
ans='true';
}
return ans;
},
type: 'siteDetails'
});
Catalog client script(inside multiline variable set)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
//Type appropriate comment here, and begin script below
var ga=new GlideAjax('siteDetails');
ga.addParam('sysparm_name','sitecheck');
ga.addParam('sysparam_id',newValue);
ga.getXML(Process);
}
function Process(response)
{
var answer=response.responseXML.documentElement.getAttribute("answer");
if(answer=='false')
{
g_form.clearValue(name1);
alert("error");
}
}
but no luck