function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandy GaliSandy Gali 

VF remoting in Salesforce1 IOS

I have a visualforce page which on click of command button calls a VF remoting function which updates my records in the background
<apex:commandButton value="Submit" action="{!Save}" onclick="updateRecordsDetails('Completed');" />
updateRecordsDetails is my VF remote function which invokes my controller methods which does the update.
Nothing fancy.

The page seemed to work fine without any issues on the salesforce website but when we oepned the VF page in Salesforce1 on IOS it doesnot work.

Has any faced similiar issue and do you know what can be the reason for this behaviour.
Best Answer chosen by Sandy Gali
bob_buzzardbob_buzzard
You have a race condition there - you have defined an action for the button which means the VF page will carry out a postback, plus you have an onclick handler for the VF remoting call which will try to make an ajax request.  If the remoting doesn't complete quickly the postback will probably break its connection.  You'll need to orchestrate these two calls to the server so that they happen in the correct sequence.

All Answers

bob_buzzardbob_buzzard
You have a race condition there - you have defined an action for the button which means the VF page will carry out a postback, plus you have an onclick handler for the VF remoting call which will try to make an ajax request.  If the remoting doesn't complete quickly the postback will probably break its connection.  You'll need to orchestrate these two calls to the server so that they happen in the correct sequence.
This was selected as the best answer
Sandy GaliSandy Gali
Hi Bob,
           Thanks alot for the prompt response. That's a very neat and simple explanation of the issue.
Can you provide some tips on how to sequence the calls

 
bob_buzzardbob_buzzard
Sure. if the action needs to complete followed by the remoting, use an actionstatus and you can execute your remoting using the oncomplete attribute. You'll need to add a rerender to your commandbutton to turn it into an ajax request. If the remoting goes first, create an actionfunction for the 'Save' action and execute that from the response handler for the remoting.