2

how to pass prior and current value to apex when record changes through process builder?

ex: when the field update occurs like contact last name using process builder.. how to pass the prior and updated value as a parameter to apex method.

any ideas appriciated. thank you

4

This can be achieved using below Class and Process Builder:

public class PrintInvocable {

public class MyInvocableVariable {
    @InvocableVariable(label='Id' required=true)
    public Id recId;

    @InvocableVariable(label='Old Value' required=true)
    public String oldVal;

    @InvocableVariable(label='Current Value' required=true)
    public String currVal;
}

@InvocableMethod(label='Old and Current Value' description='Print Old and Current Values')
public static void printOldAndCurrentValues(List<MyInvocableVariable> myInvocableVariableList) {

    for(MyInvocableVariable myInvocableVariable : myInvocableVariableList) {
        system.debug('recId=' + myInvocableVariable.recId + ', oldVal=' + myInvocableVariable.oldVal + ', currVal=' + myInvocableVariable.currVal);            
    }
}

}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.