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
Simon GAZINSimon GAZIN 

How to check the current DeveloperName in RecordType?

Hello, 

 

I'm on a project together Trigger on Task SObject in this class Trigger a call must be made according to the DevelopperName.
I can not encode the current recovery DevelopperName.
And how to test the current DelopperName ?

Thank you.
Simon

Best Answer chosen by Admin (Salesforce Developers) 
RockzRockz

Hi..

 

Hope this will help :

 

http://salesforce.stackexchange.com/questions/20976/how-to-check-the-current-developername-in-recordtype

 

Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.

 

Thanks,

Cool Sfdc

 

All Answers

Abhi_TripathiAbhi_Tripathi

Hi,

 

You need yo just check in your trigger that which recordType OR developerName is that.

 

//Like this
for(Task tsk : Trigger.new) {

    if(tsk.recordType.DeveloperName == 'YOUR_DEVELOPER_NAME') {
            
          //your login here
    }
}

 

Simon GAZINSimon GAZIN

Thank you for your quick responce.

The code seems simple and clear compared to what I could see. But this error appear on Eclipse : Loop variable must be of type SObject

 

Subhash GarhwalSubhash Garhwal
Can you post your code where you getting this error
Simon GAZINSimon GAZIN
List< String >	ListID_RecordTypeTask	=	new List< String >();	
/*0*/	ListID_RecordTypeTask.add( RecordTypeForTest.getRecType('Task', 'DevelopperName1'));
/*1*/	ListID_RecordTypeTask.add( RecordTypeForTest.getRecType('Task', 'DevelopperName2'));
/*2*/	ListID_RecordTypeTask.add( RecordTypeForTest.getRecType('Task', 'DevelopperName3'));
/*3*/	ListID_RecordTypeTask.add( RecordTypeForTest.getRecType('Task', 'DevelopperName4'));
/*4*/	ListID_RecordTypeTask.add( RecordTypeForTest.getRecType('Task', 'DevelopperName5'));	
	
for(Task tsk: trigger.new) { // Error is here
    if(tsk.recordType.DeveloperName == ListID_RecordTypeTask[0]) { 
        // Call ApexClass
    }
}

 Here is my code

Subhash GarhwalSubhash Garhwal

Hi,

 

I didn't understand why you doing this, to check record type developerName you can simply check

 

task.recordType.DeveloperName = 'DeveloperName(API Name) of record Type';

 

Thanks

 

Hit the Kudos button (star)  and Mark as solution if it post helps you

RockzRockz

Hi..

 

Hope this will help :

 

http://salesforce.stackexchange.com/questions/20976/how-to-check-the-current-developername-in-recordtype

 

Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.

 

Thanks,

Cool Sfdc

 

This was selected as the best answer
Simon GAZINSimon GAZIN

@

task.recordType.DeveloperName

 In my system, SObject Task.RecordTypeId and SObject RecordType.DevelopperName.

 

@

Thank you for your help. But I'm lost with your code. I wanted to see with other reviews.

 

I apologize for not understanding directly. I started the Apex language there is just one month and I do not have any property identified