You need to sign in to do that
Don't have an account?

how to write test class for the trigger
i want to write the test class for the trigger
trigger ChangeRecordTypetoBussinessAccount on Account (before insert) {
IF(Trigger.Isbefore||Trigger.IsAfter ){
Map< String,Id> typeMap = New Map< String,Id>();
for(RecordType rt: [Select DeveloperName, Id From RecordType Where sObjectType = 'Account']) {
typeMap.put(rt.DeveloperName,rt.Id);
}
for (Account cc : trigger.new) {
if (cc.Rec_type_Bussiness_Account_hidden__c == 'Labs Sales' && cc.IsPersonAccount == False) {
if(typeMap.containsKey('Business_Account'))
cc.RecordTypeid = typeMap.get('Business_Account');
}
}
}
}
You can try the below snippet and modify it as per your use case:
Please do note that this is a snippet and you need to modify it as per your usecase.
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.
Thanks.
All Answers
You can try the below snippet and modify it as per your use case:
Please do note that this is a snippet and you need to modify it as per your usecase.
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.
Thanks.
Thanks @ANUTEJ