• abcd1234
  • NEWBIE
  • 0 Points
  • Member since 2011

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

When a parent account is inactivated ( A custom field 'Inactive' , wil be set to true), then all the opportunites for that account & opportunities of the child accounts should be transferred to 'Opportunity Deleted' stage and owner of the opportunites ha s to be changed.

 

When Iam trying to do this. am getting errors like:

1. Apex trigger INACTIVATE_TRIGGER caused an unexpected exception, contact your administrator: INACTIVATE_TRIGGER: System.LimitException: Too many SOQL queries: 101

 

2. self-recursion :

Cannot recursively update itself

 

Can someone help me in this?

 

Thanks

Hi,

 

How to have an explicit 'COMMIT' in Apex?

 

In before update trigger we need to check a condition, and if that condition is satisfied the value of a field has to be changed and an error has to be thrown. As the transaction will be commited in the last, the changes to the field are not being saved as an error will be thrown.Hence a mechanism to commit the change to field before throwing the error. Is there any such mechanism in Apex.

 

 

I am facing some issue in below scenario.

 

 

Whenever opportunity stage is changed to "closed won" message should be displayed on top of the page as “Approval Required”.

 

And Stage should remain same as earlier until supervisor approves it.

 

After approval of supervisor stage should change to closed won.

 

Please help me in resolving this issue.

    Hi,

 

I have written a trigger for before update function

 

 

The trigger which iam running is

 

 

trigger stage_won on Opportunity (before update) {

 

     

   for (opportunity a : Trigger.new)        

   {             

    if ((a.StageName=='Closed Won')&&(a.Status__C!='Approved')&&(a.Requesting_Stage__c==null))

    {

      opportunity convertedopp = [select StageName,Requesting_Stage__c from opportunity where id = :a.id];

      convertedopp.Requesting_Stage__c = 'Closed Won';

      Update convertedopp;

      a.addError('Approval Required');

                  

     }

     }

     }

 

 

Its throwing the below error.

 

 

 

 

 

Apex script unhandled trigger exception by user/organization: 005N0000000Hdze/00DN00000000NEt Source organization: 00D90000000KgmL (null)

stage_won: execution of BeforeUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 006N0000001qx7SIAQ; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 006N0000001qx7S) is currently in trigger stage_won, therefore it cannot recursively update itself: []

Trigger.stage_won: line 10, column 7

 

How to restrict user to add a single product to an opportunity?

When a parent account is inactivated ( A custom field 'Inactive' , wil be set to true), then all the opportunites for that account & opportunities of the child accounts should be transferred to 'Opportunity Deleted' stage and owner of the opportunites ha s to be changed.

 

When Iam trying to do this. am getting errors like:

1. Apex trigger INACTIVATE_TRIGGER caused an unexpected exception, contact your administrator: INACTIVATE_TRIGGER: System.LimitException: Too many SOQL queries: 101

 

2. self-recursion :

Cannot recursively update itself

 

Can someone help me in this?

 

Thanks

I am facing some issue in below scenario.

 

 

Whenever opportunity stage is changed to "closed won" message should be displayed on top of the page as “Approval Required”.

 

And Stage should remain same as earlier until supervisor approves it.

 

After approval of supervisor stage should change to closed won.

 

Please help me in resolving this issue.

    Hi,

 

I have written a trigger for before update function

 

 

The trigger which iam running is

 

 

trigger stage_won on Opportunity (before update) {

 

     

   for (opportunity a : Trigger.new)        

   {             

    if ((a.StageName=='Closed Won')&&(a.Status__C!='Approved')&&(a.Requesting_Stage__c==null))

    {

      opportunity convertedopp = [select StageName,Requesting_Stage__c from opportunity where id = :a.id];

      convertedopp.Requesting_Stage__c = 'Closed Won';

      Update convertedopp;

      a.addError('Approval Required');

                  

     }

     }

     }

 

 

Its throwing the below error.

 

 

 

 

 

Apex script unhandled trigger exception by user/organization: 005N0000000Hdze/00DN00000000NEt Source organization: 00D90000000KgmL (null)

stage_won: execution of BeforeUpdate

caused by: System.DmlException: Update failed. First exception on row 0 with id 006N0000001qx7SIAQ; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 006N0000001qx7S) is currently in trigger stage_won, therefore it cannot recursively update itself: []

Trigger.stage_won: line 10, column 7

 

How to restrict user to add a single product to an opportunity?