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
ATHUL MATHEW 18ATHUL MATHEW 18 

prevent AutoCall when redirected to record from notification bell

we have an AutoCallController which uses StandardController sc to autocall whenever a user opens that record, but i need to prevent when redirect occur from Bell Icon notification of that record..pls help
Best Answer chosen by ATHUL MATHEW 18
Prateek Prasoon 25Prateek Prasoon 25
To prevent AutoCall from running when a user is redirected to a record from a notification bell, you can add a check in the AutoCallController to see if the user was redirected from a notification. Here's an example of how you can modify the code to achieve this:
public class AutoCallController {

    private ApexPages.StandardController sc;

    public AutoCallController(ApexPages.StandardController sc) {
        this.sc = sc;
        if(!isRedirectedFromNotification()) {
            autoCall();
        }
    }

    private void autoCall() {
        // Perform auto call logic
    }

    private Boolean isRedirectedFromNotification() {
        String referrer = ApexPages.currentPage().getHeaders().get('Referer');
        return referrer != null && referrer.contains('/notification/notifications');
    }
}

If you find this answer helpful, Please mark it as the best answer.