You need to sign in to do that
Don't have an account?
IT 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")))))
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")))))
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>