Last Chance! Our Annual Community Survey Closes 3/29 | Win a $25 Gift Card!

Shape our community's future - Quick survey. Big impact. Participate Now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

getXMLWait() does not work in Service Portal

pradeepgupta
Giga Expert

Hi Friends,

As getXMLWait does not works in Service Portal, what can be an alternative of same to hold browser execution till the time server sends

response to client side.

I have used getXMLAnswer in catalog client script , however it does not holds browser for the response from server and continues with next

line code   execution.

Please help me to address above query.

6 REPLIES 6

BALAJI40
Mega Sage

Hi pradeep,



Yes synchronous calls will not support in service portal, try with assynchronous calls. Based on your script you can modify. paste your code here if any alternative is there we can modify that.


Hi Balaji,



Thanks for your quick response.



Asynchronous call will not help me as I am looking for validation (OnSubmit) and want to hold execution of code (browser) till the the we receive response.



Please find the below code:


-


function onSubmit() {


  //Type appropriate comment here, and begin script below


  var requested_for=g_form.getValue('u_requested_for');


  var start_date=g_form.getValue('u_start_date');


  var end_date=g_form.getValue('u_end_date');


  var no_of_days=g_form.getValue('u_number_of_days');


  var leave_type=g_form.getValue('u_leave_type');


  //alert('Start');



  var ajax = new GlideAjax('ClientScriptProcessing');


  ajax.addParam('sysparm_name','requestValidation');


  ajax.addParam('sysparm_strt',start_date);


  ajax.addParam('sysparm_end',end_date);


  ajax.addParam('sysparm_requestedfor',requested_for);


  ajax.addParam('sysparm_leavetype',leave_type);


  ajax.addParam('sysparm_noofdays',no_of_days);


  ajax.getXMLAnswer(setAnswer);



  function setAnswer(response)


  {


  var resultResponse = response;


  if(resultResponse=='noEntitlement')


  {


  // g_form.addErrorMessage('You are not entitled for requested leave type');


  alert('You are not entitled for requested leave type');


  // g_form.setValue('u_leave_type','');


  return false;


  }


  else if (resultResponse=='noLeaveBalance' )


  {


  g_form.addErrorMessage('You do not have sufficient balance for requested leave type');


  g_form.setValue('u_leave_type','');


  return false;



  }



  else


  {alert('Proceed to request creation:'+response);


  //return false;


  }


  }


}



------------------------


I am getting the response from server and accordingly message is getting displayed , however it is not restricting and allowing the request to be submitted.


you can do with one customized solution for that. first convert your code to assynchronous onSubmit()


1) create one true/false or yes/no type.


2) when ever onSubmit script executes, the field should be false only.


3) Create one more onSubmit script which will validate on created field, when ever false, form should not submit.


4) Overall the script executes, if it execution is true make the field to true, or make it to false.



This will be some solutions, which we are implemented, but you can change the alert message based on that.


Hi Balaji,



I tried this approach but is it not working for me.



Have you tries this and was it work for you?



Thanks,