You need to sign in to do that
Don't have an account?
Ying Ding 6
REST API POST Trigger Visual Force Page Popup
Hi, I am a newbie to SFDC, and very excited learning tons of new stuff here. Now I have a question that, if I have a controller which serves as REST API Web Service endpoint and receiving the external parties' post information. can I trigger some actions such as popup/alert in the associated VF page?
Part of my code is pasted below.I was trying to trigger the popup by calling the action function in the httppost function, but failed. Can somebody please help me? Any advice will be very appreciated. Thank you!
--Controller
@HttpPost
global static boolean getPost(String matrics) {
boolean received = false;
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(matrics);
postID = (String)params.get('ID');
userId = 'myid123';
if(userID.equals(postID)){
received=true;
showPopup(); //change the displayPopUp from false to true
}else{
received=false;
closePopup();//change the displayPopUp from true to false
}
return received;
}
--VF Page
<apex:outputPanel id="TestPopup">
<apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
<apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
This is where I would put whatever information I needed to show to my end user.<br/><br/><br/>
<apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="TestPopup"/>
</apex:outputPanel>
</apex:outputPanel>
Part of my code is pasted below.I was trying to trigger the popup by calling the action function in the httppost function, but failed. Can somebody please help me? Any advice will be very appreciated. Thank you!
--Controller
@HttpPost
global static boolean getPost(String matrics) {
boolean received = false;
Map<String, Object> params = (Map<String, Object>)JSON.deserializeUntyped(matrics);
postID = (String)params.get('ID');
userId = 'myid123';
if(userID.equals(postID)){
received=true;
showPopup(); //change the displayPopUp from false to true
}else{
received=false;
closePopup();//change the displayPopUp from true to false
}
return received;
}
--VF Page
<apex:outputPanel id="TestPopup">
<apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
<apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
This is where I would put whatever information I needed to show to my end user.<br/><br/><br/>
<apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="TestPopup"/>
</apex:outputPanel>
</apex:outputPanel>
Use asynchronous callouts to make long-running requests from a Visualforce page to an external Web service and process responses in callback methods. Asynchronous callouts that are made from a Visualforce page don’t count toward the Apex limit of 10 synchronous requests that last longer than five seconds. As a result, you can make more long-running callouts and you can integrate your Visualforce pages with complex back-end assets.
An asynchronous callout is a callout that is made from a Visualforce page for which the response is returned through a callback method. An asynchronous callout is also referred to as a continuation.
Refer this links
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_overview.htm
https://rajvakati.com/2018/03/08/asynchronous-callouts-from-visualforce-pages-with-continuations/
http://eltoro.force.com/MakeLongRunningCalloutsFromVisualforcePagesUsingTheContinuationPattern
https://www.mstsolutions.com/technical/long-running-callouts-in-salesforce/
https://www.jitendrazaa.com/blog/tag/continuation/
Were you able to figure out a way to handle the above scenario? Please share if you did. I also have a similar requirement now.