replicate custom button from Salesforce classic in Skuid

  • 1
  • Question
  • Updated 9 months ago
  • In Progress

I'd like to replicate the behavior from a custom button built for us by a consultancy in the classic interface, into a new Skuid page built by me. My understanding is that it's not possible to call a custom button from Skuid, or at least it doesn't appear as an option under the "Run Salesforce Action", which is a shame, as I don't have the best understanding of what the button does.


Currently the custom button calls a visualforce page (see screenshot)


It calls this visualforce page


Which calls this apex class:

public with sharing class MergerOverrideExtension {

    public Merger__c controllerMerger { get; set; }
    public MergerServices mergerService;

    private CDFIntegration cdfIntegration;

    private MergingAccountService mergerAccountService;

    public MergerOverrideExtension(ApexPages.StandardController controller) {
        this(controller, new CDFIntegration());
    }

    @TestVisible
    private MergerOverrideExtension(ApexPages.StandardController controller, CDFIntegration cdfIntegration) {
        this.cdfIntegration = cdfIntegration;
        this.controllerMerger = (Merger__c)controller.getRecord();
        this.mergerService = new MergerServices(cdfIntegration);
        this.mergerAccountService = new MergingAccountService();
    }

    public PageReference saveMerger() {

        try {
            upsert controllerMerger; // this should trigger a flow to insert the merging accounts?
        } catch (DMLException e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getDmlMessage(0)));
            return null;
        } catch (Exception e) {
            ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, e.getMessage()));
            return null;
        }

        return new ApexPages.StandardController(controllerMerger).view();
    }

    public PageReference initiateMerger() {
        return mergerAccountService.initiateMerger(controllerMerger, mergerService);
    }

    public PageReference abandonMerger() {
        return mergerAccountService.abandonMerger(controllerMerger, mergerService);
    }

}

Which displays an error message like this in classic:




From what I've read, I need to change class above to make it "invocable". Making it invocable will mean I can use the method in Skuid, with it appearing as an apex action. Is there anyone that can help me change my apex class to do this please, or just anyone able to suggest a declarative alternative?

Thanks

Glenn





Photo of Glenn Daly

Glenn Daly

  • 1,686 Points 1k badge 2x thumb

Posted 9 months ago

  • 1
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 12,250 Points 10k badge 2x thumb
Hi Glenn,

It sounds like you may already have reviewed Skuid's documentation regarding this, but I wanted to share the link just in case. 

These Salesforce documents should also be helpful:
https://developer.salesforce.com/docs/atlas.en-us.204.0.apexcode.meta/apexcode/apex_classes_annotati...
https://developer.salesforce.com/docs/atlas.en-us.204.0.apexcode.meta/apexcode/apex_classes_annotati...

I think it will be important to understand your existing Apex well enough to be able to annotate it as invokable, as our documentation recommends. 

There could be a declarative option to uncover, that uses Skuid's action framework. Can you describe what the button does from a user or record standpoint?
(Edited)
Photo of Glenn Daly

Glenn Daly

  • 1,686 Points 1k badge 2x thumb
Hi Mark

Yes I have reviewed the documentation you mention.I have also found some technical documentation for the "Abandon Merger" button. The diagram below explains what happens.



Note that if the web service throws an exception, this will be reported back to the user in the form of an error message, and the abandon merger stops.