• JIDzenprise
  • NEWBIE
  • 25 Points
  • Member since 2011

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

I'm using the following code to grab the Partner on an Opportunity and populate a custom field on the Account called Partner Account. For some reason every once in a while it throws an error that states that there's a circular dependency. Can someone point me in the right direction to figure out how to fix this?

 

trigger PopulatePartnerOnAccountFromList2 on Opportunity (before update) {
// THIS TRIGGER WILL OVERWRITE ANY PARTNER DEFINED IN THE FIELD Partner ON THE ACCOUNT OBJECT.
// SET THIS FIELD TO READ ONLY OR CHANGE THE FUNCTIONALITY BELOW TO AVOID DATA BEING OVERWRITTEN BY MISTAKE...

   for (Opportunity o : Trigger.new) {
  

 


       // CREATE ARRAY OF ALL PARTNERS ON THIS OPPORTUNITY. THE REASON WHY WE DONT PICK THE PRIMARY PARTNER ONLY
       // IS BECAUSE THE PRIMARY FLAG IS NOT ALWAYS SET WHEN PARTNERS ARE ADDED TO OPPORTUNITIES. ONLY WHEN SALES DOES TIS
       // MANUALLY FROM THE RELATED LIST IS PRIMARY CHECKBOX CHECKED...


       OpportunityPartner[] PartnerArray = 
       [select AccountToID, IsPrimary from OpportunityPartner where OpportunityId = :o.id ORDER BY isPrimary DESC, CreatedDate];
       if (PartnerArray.size() > 0) {
         
           // IF PRIMARY IS DEFINED THEN THIS WILL BE THE FIRST OBJECT. IF NOT THE FIRST ADDED PARTNER WILL BE ADDED...
                     List<Account> AccountArray = [select id,Partner_Account__c from Account where Id = :o.AccountId ];
           for (Account a: AccountArray ){
                       a.Partner_Account__c=PartnerArray[0].AccountToID;
            update a;
                       }
            
       }
   }
 }

 

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger UpdateAccountPartner caused an unexpected exception, contact your administrator: UpdateAccountPartner: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0014000000b5gNsAAI; first error: CIRCULAR_DEPENDENCY, attempt to violate hierarchy constraints: []: Trigger.UpdateAccountPartner: line 24, column 1

 

 

I've got this trigger halfway there whereby it will update Opportunity Description with the Partner ID from the Partner on the related list. I only did it this way to make sure the value being returned was the one I wanted. Anyway, I need this to update a custom Partner Account look up field on the Account Object. (I'm new to this). Can anyone point me in the right direction in terms of what I need to do next?

 

trigger PopulatePartnerOnAccountFromList on Opportunity (before update) {
// THIS TRIGGER WILL OVERWRITE ANY PARTNER DEFINED IN THE FIELD Partner ON THE ACCOUNT OBJECT.
// SET THIS FIELD TO READ ONLY OR CHANGE THE FUNCTIONALITY BELOW TO AVOID DATA BEEING OVERWRITTEN BY MISTAKE...

   for (Opportunity o : Trigger.new) {
   
 


       // CREATE ARRAY OF ALL PARTNERS ON THIS OPPORTUNITY. THE REASON WHY WE DONT PICK THE PRIMARY PARTNER ONLY
       // IS BECAUSE THE PRIMARY FLAG IS NOT ALWAYS SET WHEN PARTNERS ARE ADDED TO OPPORTUNITIES. ONLY WHEN SALES DOES TIS
       // MANUALLY FROM THE RELATED LIST IS PRIMARY CHECKBOX CHECKED...


       OpportunityPartner[] PartnerArray =
       [select AccountToID, IsPrimary from OpportunityPartner where OpportunityId = :o.id ORDER BY isPrimary DESC, CreatedDate];
       if (PartnerArray.size() > 0) {
         
           // IF PRIMARY IS DEFINED THEN THIS WILL BE THE FIRST OBJECT. IF NOT THE FIRST ADDED CONTACT ROLE WILL BE ADDED...
           o.Description = PartnerArray[0].AccountToID;
          
       }else{
      
           // IF NO PARTNERS EXIST RETURN NULL...
           o.Description = null;
                 }
   }
 }

 

Hi,

 

I am sirprised to see this error on my visual force page which is used to customize the Sales Team functionality. The same was working fine for last few months . There was no reference to the currencyIsoCode both in page/controller as well. I guess this has some thing to do with the recent updated to the Sales Team object. But I am unable to find out the exact issue. Did any one came across or knew about this. Please help me out.

 

 

--yvk

  • September 18, 2012
  • Like
  • 0

I've got this trigger halfway there whereby it will update Opportunity Description with the Partner ID from the Partner on the related list. I only did it this way to make sure the value being returned was the one I wanted. Anyway, I need this to update a custom Partner Account look up field on the Account Object. (I'm new to this). Can anyone point me in the right direction in terms of what I need to do next?

 

trigger PopulatePartnerOnAccountFromList on Opportunity (before update) {
// THIS TRIGGER WILL OVERWRITE ANY PARTNER DEFINED IN THE FIELD Partner ON THE ACCOUNT OBJECT.
// SET THIS FIELD TO READ ONLY OR CHANGE THE FUNCTIONALITY BELOW TO AVOID DATA BEEING OVERWRITTEN BY MISTAKE...

   for (Opportunity o : Trigger.new) {
   
 


       // CREATE ARRAY OF ALL PARTNERS ON THIS OPPORTUNITY. THE REASON WHY WE DONT PICK THE PRIMARY PARTNER ONLY
       // IS BECAUSE THE PRIMARY FLAG IS NOT ALWAYS SET WHEN PARTNERS ARE ADDED TO OPPORTUNITIES. ONLY WHEN SALES DOES TIS
       // MANUALLY FROM THE RELATED LIST IS PRIMARY CHECKBOX CHECKED...


       OpportunityPartner[] PartnerArray =
       [select AccountToID, IsPrimary from OpportunityPartner where OpportunityId = :o.id ORDER BY isPrimary DESC, CreatedDate];
       if (PartnerArray.size() > 0) {
         
           // IF PRIMARY IS DEFINED THEN THIS WILL BE THE FIRST OBJECT. IF NOT THE FIRST ADDED CONTACT ROLE WILL BE ADDED...
           o.Description = PartnerArray[0].AccountToID;
          
       }else{
      
           // IF NO PARTNERS EXIST RETURN NULL...
           o.Description = null;
                 }
   }
 }

 

I have a customer still using Yammer and they are slowly trying to move over to Chatter. If they could post emails directly into Chatter that would help with the transition. I installed the email2Chatter app but all it seems to do is update my wall. It does not seem possible to instruct it to update a group and I wanted to verify that it was not possible before sharing that with the customer. Any thought would be appreciated.

Im trying to use a apex script that i have found. But it seems like it does not take care of the problem of opportunities not having a primary contact. If the primary contact is not defined it throws the following error.

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger trgMnCopyPrimaryContact caused an unexpected exception, contact your administrator: trgMnCopyPrimaryContact: execution of BeforeUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Trigger.trgMnCopyPrimaryContact: line 6, column 13

 

trigger trgMnCopyPrimaryContact on Opportunity (before update) {

   for (Opportunity o : Trigger.new) {

       OpportunityContactRole contactRole =
            [select ContactID from OpportunityContactRole where IsPrimary = true and OpportunityId = :o.id];

       if (contactRole != null) {
         o.Opportunity_contact__c = contactRole.ContactID;
       }

   }

 }

 

 

Im not a java developer and wonder if someone can help me to add functionality that does not fail if the primary contact is missing.

I have a requirement to prevent users from deleting Activity Histories for one standard object only.

 

I've looked and there isn't an option to hide visibility of the "delete" link or set permissions to prevent users from deleting the Activity History.

 

I've also explored the possibility of writing a trigger, but it seems like there isn't an option of creating a trigger on the ActivityHistory object.

 

Any ideas or suggestions?

  • July 17, 2009
  • Like
  • 0

Hello,

I am using a soql query to retrieve records from contact.

Here is my query:

List<contact> contactList=[Select name,Email from contact where id=:contactId];

 

I am able to execute this if i have less records but if i have more records that is fr about 200 Records i am getting an exception:

Too many SOQL queries: 101 .

 

When i looked for this Exception  i came to know that a database statement cannot process more than 100 records. 

 

Is there any method to overcome this issue please help me out with code if any.

 

Please help me out of this issue.

 

Thanks in advance,

prashanth. 

 

 

  • July 04, 2009
  • Like
  • 0

Hi All,

 

We have a requirement wherein a field can have any values between 0-9 or special characters comma,spaces,"+","-",";","/",".","(",")". Other than this a user should not be able to enter anything.

 

Need to write a custom validation rule for this. But not able to achieve the desired functionality. Please help me how to achieve it

 

Thanks in advance

Priya Nair

  • February 10, 2009
  • Like
  • 0