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

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' &&'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.

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
Hi Ashok,

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

Abhi Tripathi
Salesforce Developer
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
Closed Won
Closed Won
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
Hi , I'd like to add you to my professional network on LinkedIn. - Ashok Accept: You are receiving Invitation emails. Unsubscribe here:∣=-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: © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA