• ysr
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

How to Lock the Case  Record when it contains open Tasks i.e. task Status = open

  • September 09, 2010
  • Like
  • 0

Hi,

 

We have a Batch class which is scheduled to run every day. This batch will update a specific user with role to a custom field on Oppty.

The problem is that we have a Validation rule on Oppty, because of which some Batches are failing.

I want to bypass this validation rule while the Batch job is running.

 

Is the below code snippet correct?

 

*************************************************************************************************************************************

 try{    
      update opp; //This is the Oppty which we are updating
      }
     
      Catch(Exception e)
      {
         string sErrMsg=e.getmessage();
       if(sErrMsg.contains('Opportunities can only be created for active Prospects/Customers.You are unable to create this opportunity because either your prospect has not been approved yet or Prospect/Customer record is inactive--which will require onboarding the Prospect/Customer.'))
           return;
      }

 

*************************************************************************************************************************************

will this piece of code bypass the validation rule and will this help the batches to run successfully?

  • April 16, 2013
  • Like
  • 0