You need to sign in to do that
Don't have an account?
Dixit
RecordType.Name on Trigger
I have a Trigger on Opportunity which is working fine except for 1 field....
The "run.recordtype.name" returns null
but if i change that line to "run.recordtypeid" it shows me the recordtype ID indeed.
I tried with and without the "string.valueof()" and still getting "null"...and checked out the recordtype and it does have a name....
(I cut the code, so sorry if there is not a "{", "}", or anything written)
What am i doing wrong?
for(Opportunity run: Trigger.new){ Opportunity old = Trigger.oldMap.get(run.Id); if (trigger.isupdate && run.invitar_al_centro_de_experiencia__c == true && old.invitar_al_centro_de_experiencia__c == true ) { invitacion_al_centro_de_experiencia__c cand = new invitacion_al_centro_de_experiencia__c(); cand = [SELECT id, name FROM invitacion_al_centro_de_experiencia__c WHERE oportunidad_relacionada__c =: run.id LIMIT 1]; cand.Tipo_de_Oportunidad__c = string.valueof(run.recordtype.name); } }
The "run.recordtype.name" returns null
but if i change that line to "run.recordtypeid" it shows me the recordtype ID indeed.
I tried with and without the "string.valueof()" and still getting "null"...and checked out the recordtype and it does have a name....
(I cut the code, so sorry if there is not a "{", "}", or anything written)
What am i doing wrong?
All Answers
http://salesforce.stackexchange.com/questions/13567/why-am-i-not-getting-the-record-type-name-when-i-use-recordtype-name
Thank you, i read about that method but i thought it was not used in my case... I thought "RecordType" was like any other find field which you can access with the "__r.name"
Thanks a lot.