Salesforce - runs an automatic response rule after creating a case through the API

I am using the Salesforce REST API to create a Case. I assign the SuppliedEmail field to the email of the user creating this case, as well as all other required fields. The case was correctly created in salesforce, but the autoresponder rule set for it does not start. I checked that the rule works and is active, all the conditions for the rule are met, so there is no question of a rule that does not match.

The problem is that salesforce does not evaluate / run the automatic response rules after creating the case through the API. Through the SOAP API you can install this using EmailHeader , but I cannot find a way to install this through the REST API.

To be clear, I am making a POST request in a URI /sobjects/Casewith the JSON value of the case itself as the request body.

Is there a way to set the field EmailHeader.triggerAutoResponseEmailto true using the REST API, perhaps through some additional field in the request body?

+3
source share
3 answers

Well, less complexity almost always comes at the expense of less features. Losing API headers is one of them. At least in Java, you can use WSDL correctly using the many available toolkits. In .NET, WCF is almost useless because MS thinks SOAP headers aren't cool (standards will be damned).

, WSDL/SOAP , Case .

+1

.

REST API APEX, . , REST API, . , APEX, - :

trigger AfterCaseInsert on Case (after insert) {

    if (trigger.isAfter && trigger.isInsert) {

        List<Case> newlyInsertedCases = [SELECT Id From Case WHERE Id IN :trigger.new];

        Database.DMLOptions autoResponseOptions = new Database.DMLOptions();
        autoResponseOptions.EmailHeader.triggerAutoResponseEmail = true;

        for (Case c : newlyInsertedCases ) {
            Database.update(c, autoResponseOptions); 
        }   

    }
}

DMLOptions EmailHeader, . WSDL/SOAP, . Case - . , , .

+1

could not comment (yet), but I could not get the dml parameters to call the auto-reply rules. I ended up just creating email on top, which could limit email in the extreme. the only difference was that I did not use dml through the trigger on the case, I used it in the quiescent class, which created the case by defining case variants and inserting them using dml.insert (case, options). a case was created, the automatic response rules did not work

0
source

All Articles