getXML() vs getXMLAnswer()? which is the best to use?

mallikharjunasw
Tera Contributor

getXML() vs getXMLAnswer()? which is the best to use?

1 ACCEPTED SOLUTION

Chris M3
Tera Guru

 

getXMLAnswer() saves you a line of code every time you use it.  That is it.  There shouldn't be any noticeable difference in speed, though this method is probably guaranteed to be slightly slower as it runs at least one more line of code each time.  So ease of use vs minuscule difference in speed. 

with getXMLAnswer() uou no longer need this line of code.

var comments = response.responseXML.documentElement.getAttribute("answer");

View solution in original post

10 REPLIES 10

MsM
Tera Contributor

One interesting fact about getXMLAnswer() method is that they are asynchronous in nature and they might not work with onSubmit client script because till they return answer onsubmit process might have been completed already.

So to avoid this situation you would use synchronous method i.e. getXMLWait() but this method also has some implications as its not accessible in Scoped app and in servicePortal.

So the best approach would be to create onChange scripts to validate user input when values are entered, rather when submitting the form. You could also enforce input validation with a Before Insert business rule and notify user for invalid input via messages.