Clear Value is not working on client script?

ch_naresh207
Giga Expert

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'

});

 

10 REPLIES 10

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..?

we don't need two client script. clearValue() is trick (as suggested by David) in your case I believe.

But I tried as suggested by david, that is not working. 

so you mean to say, you have two client script with same GlideAjax call? and It's working?

Kunal Jha
Giga Expert

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;

},