Clear Value is not working on client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 06:06 AM
I have validated Single text variable if existing table record is there or not. If is there need to show up alert message and need to clear the value.
here alert is working fine , but clear value is not working.
*** once I added g_form.setValue('new_site_url',''); then keep on clearing the variable value , even the record is not there in table:
Alert popup is working ,With out 'g_form.setValue('new_site_url','')' is working fine .
Could you please help me on this.
Please fin the below client script and script include --------------
client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var folderd = new GlideAjax("site_url_sharepoint");
folderd.addParam("sysparm_name", "getFolderDetails");
folderd.addParam("sysparm_new_folder_name", g_form.getValue('new_site_url'));
folderd.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
//alert(answer);
if(answer == 'true')
alert('Existing Site URL is available, please enter the new Site URL name');
g_form.setValue('new_site_url','');
}
}
===============
Script Include:
var site_url_sharepoint = Class.create();
site_url_sharepoint.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getFolderDetails: function(){
var newFolder = new GlideRecord('u_shared_folders');
newFolder.addQuery('u_folder', this.getParameter('sysparm_new_folder_name'));
newFolder.query();
if(newFolder.next())
return true;
},
type: 'site_url_sharepoint'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 06:45 AM
Thank you for the replay,
No is getting null value, i have cross checked.
I have created separate onchange client script for clearValue. Now is working fine.
Please explain me you have any idea one on this, how is working with two client scripts..?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 06:49 AM
we don't need two client script. clearValue() is trick (as suggested by David) in your case I believe.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 06:59 AM
But I tried as suggested by david, that is not working.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 07:09 AM
so you mean to say, you have two client script with same GlideAjax call? and It's working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018 08:15 AM
Naresh - your code look ok. Make few changes and see if its work.
Is client script on change of new site url ?
I assume you are getting value for answer from script include ?
client script change
if(answer == 'true')
{
alert('Existing Site URL is available, please enter the new Site URL name');
g_form.setValue('new_site_url','');
}
script Include
getFolderDetails: function(){
answer = 'false';
var newFolder = new GlideRecord('u_shared_folders');
newFolder.addQuery('u_folder', this.getParameter('sysparm_new_folder_name'));
newFolder.query();
if(newFolder.next())
answer = 'true';
return answer;
},