• Rajendra Pogiri
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
sir/mam,   i wrote a after trigger code for :-  if the amount is greater than 50,000 then the opportunity record should be shared with another user, so i in program at query i took the user-id  where euals to ALIAS name.   this is working fine.   But problem is if write the query for LASTNAME instead of ALIAS name, then i am getting error,, please help.....
 
trigger afterinsertTrigger on Opportunity (after insert) {
list share=new list();
     user u=[select id from user where lastname='pogiri'];
    for(Opportunity op:Trigger.New){
        if(op.amount>50000){
            Opportunityshare s=new Opportunityshare();
            s.OpportunityId=op.id;
            s.OpportunityAccessLevel='Edit';
            s.RowCause='Manual';
            s.UserOrGroupId=u.id;
            share.add(s);
        }
    }
      insert share;
}


User-added image