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
IT Admin 179IT Admin 179 

Soql CreatedBy.Profile.Name

i All,


How can I retrieve this variable via soql?
CreatedBy.Profile.Name  


// we code the profile name as createBy.ProfileName

IF(CONTAINS(CreatedBy.Profile.Name, "Community"),"Community Programs",IF(CONTAINS(CreatedBy.Profile.Name, "Admissions"),"Admissions",IF(CONTAINS(CreatedBy.Profile.Name, "Transition"),"Transitions",IF(CONTAINS(CreatedBy.Profile.Name, "Marketing"),"Marketing",IF(CONTAINS(CreatedBy.Profile.Name, "Admin"),"Technology","Other")))))
Glyn Anderson 3Glyn Anderson 3
Your question is a little confusing, because you ask about SOQL, but give a formula example.  So hopefully I am answering your question.

The SOQL query, [SELECT Id, CreatedBy.Profile.Name FROM Contact], works just fine.  The field name is "CreatedBy.Profile.Name", just like it is in the formula.  If you want Apex to do what the formula does, here it is:

<pre>
String label =
    record.CreatedBy.Profile.Name.contains( 'Community' )  ?  'Community Programs'
:   record.CreatedBy.Profile.Name.contains( 'Admissions' )  ?  'Admissions'
:   record.CreatedBy.Profile.Name.contains( 'Transition' )  ?  'Transitions'
:   record.CreatedBy.Profile.Name.contains( 'Marketing' )  ?  'Marketing'
:   record.CreatedBy.Profile.Name.contains( 'Admin' )  ?  'Technology'
:   'Other';
</pre>
Glyn Anderson 3Glyn Anderson 3
Did this answer solve your problem?  If so, please mark the question as "Solved".  If not, let me know - I'm happy to help more.  If you solved the problem another way, please post your solution for everyone's benefit.  Thanks!
Glyn Anderson 3Glyn Anderson 3
Do you need any more help with this?  If not, please mark it as "Solved".  You can post your solution as the Best Answer.  Thank you!