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

how to identify record type in trigger
I'm going to create a trigger on case object, this trigger should only invoke when the case're record type is "XXX", "XXX" is one of the record type of case, can someone help me figure out the code to identify the report type is "XXX". the following script doesn't work.
if(Trigger.new[i].RecordType == 'Partner Case'){
All Answers
Thanks! However, how to identify the recordtypeid? I only know the name, such as "Partner Case".
Use Apex explorer or Saelsforce Schema to find out the recordtypeid of any recordtype
The query wud like as:
Select Id, Name from RecordType
hope it helps :)
Re below, you can just assign the id you want to check for to a variable using a select like below, and then compare to the record in the trigger:
Id PartnerCaseId = [Select Id, Name from RecordType where name = 'Partner Case' limit 1].Id;//Then compare:if(Trigger.new[i].RecordTypeId == PartnerCaseId)
There is also a a specific method to query for the record types for an object, though just doing a Select as suggested should be enough for you. But for more info about the Method, look in the apex docs and search for record types
Thanks very much for your information, I just downloaded app explorer, is it just for test, so I do some change will not affect the product.
And, can it connect to sandbox?
You can point Apex Explorer at the sandbox - go to Tools - Options, and change the end point to test.salesforce.com
Then you can login with your Sandbox credentials