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
NNRNNR 

HI friends

trigger insertCategoryScore on Opportunity (before Insert , before Update) {

    list<Opportunity> oppt = [select id, Name, StageName,Stage_Reason__c from Opportunity];
   
    List<RecordType> lstRecType = [Select Id, Name from RecordType where sObjectType = 'Opportunity'];
    //RecordType lstRecType[] = [Select Id, Name from RecordType where sObjectType = 'Opportunity'];
   
    for (Opportunity opp: oppt){
    for(RecordType rec:lstRecType){
     
     if(opp.StageName =='Active Low' && rec.name=='Business1') 
       opp.Stage_Reason__c = 'Waiting Approval';
       //upsert opp;
    }
    }
 
    insert oppt;
    
}


ERROR is:Invalid field update at line17
Richa KRicha K
What are you trying to achieve? You cannot do explicit insert/update in before triggers.


Thanks,
SP
NNRNNR
Hi shailesh.patil My aim to I have 3 RecordTypes in satages: if i select "active low" and aftersaving my new record in stage Reason__c is upadate with "waiting for approval".i try after insert ,after update i got same error. Thanks and Regards Ashok Gaddam cell:98 49 51 92 76
Abhi_TripathiAbhi_Tripathi
Hi Ashok,

Check the type of the field, and re check weather you have access to that field or not.

Regards,
Abhi Tripathi
Salesforce Developer
NNRNNR
On Opportunity, Auto-populate a field ‘Stage Reason(Data Type: Text)’ based on the ‘Stage’ Selected and the Record Type of the opportunity.



STAGE                                          RECORDTYPE

ACTIVE LOW                             Business 1
Prospect
Closed Won
ACTIVE LOW
Prospect
Closed Won
NNRNNR
Hi abhi STAGES RECORDTYPE STAGE_REASON__C ACTIVE LOW BUSINESS1 WAITING FOR APPROVAL CLOSED WON BUSINESS1 APPROVED THE above is my table when i creat or edit record based on stage picklist value and RecordType the stage_Reason__c can be updated........... i try in after insert and after update also.. can you help Thanks and Regards Ashok Gaddam cell:98 49 51 92 76
NNRNNR
Hi , I'd like to add you to my professional network on LinkedIn. - Ashok Accept: https://www.linkedin.com/e/v2?e=l1u65r-hx63awcx-5o&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5890450910877863936&sharedKey=fIWTkIlo You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=l1u65r-hx63awcx-5o&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=l1u65r-hx63awcx-5o&email=3nesbnhuik2ubv6o%2Ee1qoc7hlw373ofsk%401qw5t7196ige3bef%2E1ekz%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=l1u65r-hx63awcx-5o&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA