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
Ying Ding 6Ying 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>
Raj VakatiRaj Vakati
Use continuation... 

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/
Vignesh Venkatesan 10Vignesh Venkatesan 10
Hi Ying,

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.
rkris320rkris320
Is this even possible?  Hi Ying, or Vignesh.. I need to do something similar?  A third party product sends some Account/Contact information via the REST API and I need to pop-up the VF Page or LWC page immediately after that, with the Account/Contact derived from the REST service.  Please share your thoughts. I appreciate your help.