1

This question already has an answer here:

I'm getting an error when I am call non void method from REST API class. Trying to add the Rest Response id in contract object.

trigger RestAPIcalloutTrigger on Contract (after insert , after Update) {

    Integer CaseID;

    CreateCasesByContract cc = New CreateCasesByContract();
    List<Contract> CList = New List<Contract>();
    for(Contract c : Trigger.New)
    {

        if(c.Broker_Involved__c ==  'yes' )
        { 
            c.BCR_Case_Id__c = cc.CreateCase();
            c.BCR_Case_URL__c = 'http://cases.boxerproperty.com/ViewCase.aspx?CaseID='+ c.BCR_Case_Id__c;
        }

        CList.add(c);
    }   
    Update CList;

}

The error is "Callout from triggers are currently not supported".

marked as duplicate by Adrian Larson apex Nov 2 '16 at 15:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

Callouts was never allowed in Salesforce after DML operation (and since trigger is running thhere was some): https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_timeouts.htm?search_text=callout

The way to work with this is using @future annotation: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_future.htm

which bascially send request asynchronously

  • Thanks for Help. Actually I wrote a script of REST API and now I want to insert response of rest API in contract object (Fx. getting case Return ID and I want to insert it in my contract object ) – Jerry Oct 26 '16 at 15:32

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