I am using autonaming to name the DCR.Based on the value in the dropdown the dcr is named.i.e if dropdown-selection is abc then dcr is named abc.I also need to check whether a dcr with abc name is already there or not.For this I am using a call server.But since the callserver is a separate thread, the dcr is getting saved before the call server returns.Any workaround or pointers on how this can be resolved.
I was calling the callserver in setAutoDCRPathgenerator's naming function.SetautoDCrpathGenaerator was registered in init function.But this approach is not working at all.
Thats what the reason might be as i am not sure but logically speaking this function must be called after Save only.As i have earlier stated ... call the CallServer onSaveValid... which validates your values within the DCR and then calls the script to check the existence of name.If it returns true... it will proceed with your onSaveDone and other registered events else on false provide an alert. I hope it makes sense to you.
First, callServer method itself does not return anything.
Second, you can call it from onSave, onSaveValid or anywhere else before onSaveDone, as long as your handler returns true/false the way you want it.
Third, since the callServer method is asynchronous your code continues executing immediately after the call to callServer().
CallServer provide output as a client script.. which in turn returns true or false.
Here is how I had done in one the implementation...
var timeoutID = 0;function saveValidHandler { ... IWDatacapture.callServer(service, parameters, false); timeoutID = window.setTimeout("cancelRemoteCall()", 60000); // One minute Time-Out return false;}// Abort the request by sending a blank page to the hidden frame.// Subsequent calls to callServer() will cancel any previous calls.function cancelRemoteCall() { IWDatacapture.callServer("blank.html", new Object(), true); alert('Warn your User that Save has failed'); timeoutID = 0;}// This is callServers' call back Function // Do not forget to Clear timeout so that we won't have false saving alarmsfunction resumeSave() { if (timeoutID) { window.clearTimeout(timeoutID); timeoutID = 0; } ... IWDatacapture.save(); ...}