• Subrat kumar Ray
  • NEWBIE
  • 10 Points
  • Member since 2014
  • Accenture Services

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
I have a trigger that is checking whether an opportuniycontactrole is created when opportunity is inserted.

trigger OpptyCheck on Opportunity (after insert) {   
List<OpportunityContactRole> oppContRoleList = [Select id, ContactId, OpportunityId from OpportunityContactRole Where OpportunityId IN :trigger.New];
    for(Opportunity opp : trigger.New){
        flag = false;
        for(OpportunityContactRole oppRole : oppContRoleList){
            if((oppRole.OpportunityId == opp.Id){
                flag=true;
            }
        }
        if(!Flag){
            opp.addError('No Active Contact Present. Add an active Contact.');  
        }
    }
}

Problem I am facing now is, whenever trying to insert opp this trigger prevents from insertion.
[except creating opp from contact where opportunitycontactrole will simulatneously created because in url 'ConId' property will hold value of contact ]

Please suggest how to insert an oppty from apex class.

Thanks.
/* */ is supposed to work, but doens't exclude anything from the page. How do you write comments on a VF page?

Cheers

Hi,

  

Can anybody explain what is instanceof keyword in salesforce with small example?

 

In which scenario we can use this..