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
Jugbeer BholaJugbeer Bhola 

Alert or Notification Message Approach

I am in the lightning environment using a standard page layout.  I have created a ‘Detail Page Button’ tied to a content source of ‘Visualforce Page.’  The Visualforce page executes from the custom button to call a web service.  What I would like to happen is an alert informing the user the web service call out is complete.    I would like a JavaScript message of  ‘Success’ or ‘Failure.’   There cannot be an ‘apex:command button’ or anything that will make the ‘Visualforce Page’ display.  

If it cannot be JavaScript message any type of message will be OK.
The apex:pagemessage will not work because the ‘Visualforce Page’ is never, and should never, displayed.  The only reason it exists is to call Apex.  

Many different attempts at firing JavaScript from the controller have failed. I am guessing it is locker service blocking the functionality.
Has anyone found a solution for this?  This seems like it would be pretty common to do this. 

The user wants to use standard pages.

I have added my current page and controller. 
 
<apex:page standardController="Account" extensions="AccountExtController" action="{!executeCall}">     
</apex:page>
 
public class AccountExtController {
    
    private ApexPages.StandardController standardController;	
    private Id acctID; 
    public AccountExtController(ApexPages.StandardController standardController)
    {
        acctID = standardController.getId();
    }
    
    public PageReference executeCall()
    {     
        String responseMessage = accountCallOutHelper.executeRequest('POST', 'getsomestuff', acctID);       
        //W A N T  T O  F I R E  A  M E S S A G E  H E R E!
        return new pagereference(url.getsalesforcebaseurl().toexternalform()+'/'+ acctID);
    }   
}

 
ShirishaShirisha (Salesforce Developers) 
Hi Jugbeer,

Greetings!

I don't think you need to display anything with the VF page in order to invoke ApexPages message.So,I would suggest you to use apexPages.addMessage to display after making the callout.

Please refer the sample code provided below:

https://developer.salesforce.com/forums/?id=906F00000008ktQIAQ

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Jugbeer BholaJugbeer Bhola
Thank you for your response.  I have attempted your suggestion several times.  The issue seems to be related to the fact that the visualforce page is a child of a standard page.  The visualforce page where apexPages.addMessage would have to be coded is tied to a button.  Something is supressing the apexPages.addMessage.  People must encounter this often.  I am hoping there is a solution but no one seems to have one.  Do you have another suggestion?