function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ajay0105Ajay0105 

Need Suggestion Urgently...

I am creating a opportunity in salesforce and when i change the owner to the new owner.. Previous owner will be getting changed updated in the related list of the Opportunity.team.

 

but when i am doing the same from partner portal i mean creating the opportunity and changing the owner previous owner will not be updating in the related list of the opportunity team

 

any one have any idea what exactly is the problem...

 

Method -->

 

public static void UpdateOpportunityTeam(List<Opportunity> oldOpps, List<Opportunity> newOpps){
       
        Set<Id> OppSet = new Set<Id>{};
        
        for(Opportunity opp : newOpps) {
            OppSet.Add(opp.Id);          
        }   
        List<OpportunityTeamMember>  ExistingOppTeamMembers = [SELECT OpportunityId, Id, UserId  
                                                                  FROM OpportunityTeamMember WHERE OpportunityId in :OppSet 
                                                                  AND IsDeleted = false];
      
        set<Id> OppUId = new set<id>();
       
        for(OpportunityTeamMember oppTeam : ExistingOppTeamMembers){ 
            OppUId.add(oppTeam.UserId);}
        
        List<OpportunityTeamMember>     listOppShare   = new List<OpportunityTeamMember>(); 
        set<Id> OppId = new set<id>();
    
       Set<Id> OwenerId = new Set<Id>();          
       for(Integer i=0; i<newOpps.size(); i++){         
           if (newOpps[i].OwnerId !=oldOpps[i].OwnerId && !OppUId.contains(oldOpps[i].CreatedById)){
            OppId.add(newOpps[i].Id);
            OwenerId.add(oldOpps[i].CreatedById);
            listOppShare.add(new OpportunityTeamMember(OpportunityId=newOpps[i].Id,UserId=oldOpps[i].CreatedById,TeamMemberRole='PartnerNet Member'));  
            system.debug('inside UpdateOpportunityTeam :: created new OpportunityTeamMember'+newOpps.size());      
           }
       }
       
       insert listOppShare;
       
       if(OppId.size()>0){         
       List<OpportunityShare> shares = [select Id, OpportunityAccessLevel, 
                                        RowCause from OpportunityShare 
                                        where OpportunityId IN :OppId and 
                                        RowCause = 'Team' and 
                                        UserOrGroupId IN:OwenerId];
    
       for(OpportunityShare share : shares) 
            share.OpportunityAccessLevel = 'Edit';
                                                    
       update shares;}
       //RowCause = 'Team' and 
    }

Ashish_SFDCAshish_SFDC

Hi Ajay0105
Please check if there are any required fields or hidden fields in the page or any Validation Rule errors that are not being shown in Partner Portal and also verify the trigger / method call conditions being met.
Above all enable Debug Logs and look for logs, also you may look into the post in the link below
http://boards.developerforce.com/t5/Apex-Code-Development/Trigger-NOT-working-from-Partner-Portal/td-p/154869
Regards,
Ashish, Salesforce.com