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
AbAb 

Execute trigger which not of record type X

Hello,

I have 2 record types (X and Y) on the Account object.

If i want to execute a trigger which is not X what condition i can use

thank you for suggestion
Best Answer chosen by Ab
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

First, fetch the record type id using:
Id rid = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Your Record type Name').getRecordTypeId();

Then, use the if condition:
for(Account acc : trigger.new) {
    if(acc.RecordTypeId != rid) { // check condition here
        // enter your code
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Bhandekar SahilBhandekar Sahil
Hi Sandrine,

You can use custom setting for bypass trigger.
In custom setting metion record type name for which you need to fire trigger.
and add conditon in trigger to check custom setting data.

Thanks 
Sahil Bhandekar
 
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

First, fetch the record type id using:
Id rid = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Your Record type Name').getRecordTypeId();

Then, use the if condition:
for(Account acc : trigger.new) {
    if(acc.RecordTypeId != rid) { // check condition here
        // enter your code
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer