• everlongh
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
This must be easy, but I've tried several approaches and haven't succeeded yet. My integration server makes a web service API call to update an Opportunity from our external application, then my Opportunity trigger fires on the update causing a callback to my integration server, so I get more than one API call. 

Here's the relevant part of the trigger code:

trigger outboundOpportunity on Opportunity (before insert, before update, after insert, after update) 
{
    if(trigger.isAfter && TriggerUtility.isFutureUpdate != true)
    {
        SObjectType type = trigger.new[0].getSObjectType();
        Schema.DescribeSObjectResult d = type.getDescribe();
        IntegrationCallout.alertIntegration(d.getName(), trigger.new[0].ID);
    }
    else ...

The approach I tried is described in some blog posts below using a static variable but the trigger still fires:

http://www.tehnrd.com/apex-flow-control-preventing-infinite-loops/

http://blog.jeffdouglas.com/2009/10/02/preventing-recursive-future-method-calls-in-salesforce/

I'm stuck because the call originates from the integration server so neither of these approaches will work.

The other approach I'm thinking of trying is to add a custom field and only populate it from the API so the trigger would look like this:

trigger outboundOpportunity on Opportunity (before insert, before update, after insert, after update) 
{
   
        for(Opportunity o : trigger.new)
        {
            String fromAPI = o.FromAPI__c;
            if(trigger.isAfter && fromAPI != '")
            {
               SObjectType type = trigger.new[0].getSObjectType();
               Schema.DescribeSObjectResult d = type.getDescribe();
               IntegrationCallout.alertIntegration(d.getName(), trigger.new[0].ID);
            }
    }
    else ...
 
Obviously the field would need to be reset after the update.

Can someone tell me if this will work or is there a  better way? 

 

Hi

 

 

I have a webservices class and I generate a class from wsdl and now I need to write test class for it but here there are no methods in it and only having  variables and classes, here I wrote test class creating an object for each class and Inner class also but not covered it showing 0%.

 

 

can any one help in this plz

 

 

thanks

SRS