Is it possible to create a nested IF formula field?

Is it possible to create a model formula field with nested IF statements?

I am trying to take the ObjectPermissions object and display profile names by using the profile ID that is given.

If anyone has done this or something similar, I would greatly appreciate the help.

Josef,

I don’t think you can do nested ‘IF’ statements.  I have used multiple formula fields to cascade the result of one formula field to another.  You can setup multiple ‘IF’ statements this way.

As it happens, I have created the same page that you are working on.  I setup a second model to get the PermissionSet names where the ProfileId is not null.  This model is the first in the list.

I then created 2 UI Only fields, one to lookup the Profile Name from the PermissionSet model and a second to check if the Parent.Name of the ObjectPermission starts with an ‘X’.  If it does, I show the model lookup field.  If not, I show the Parent.Name from the table model.

Here is the model lookup formula.  Field is called ‘ParentModelLookup’:

MODEL_LOOKUP("PermissionSetsProfiles","Profile.Name","Id",{{ParentId}})


Here is the IF formula to set a UI only field to display the PermissionSet/Profile Name:

IF(STARTS_WITH({{{Parent.Name}}},"X"),{{{ParentNameLookup}}},{{{Parent.Name}}})


Thanks,

Bill


Josef,

If Bill’s way works for you, by all means, you can go with it. I felt I should also let you guys know that you can do nested if statements, though. You have to get the syntax just right, but it will work. There’s a simple-ish example of a nested if on this post

Thanks!

Amy,

Thanks for posting the sample.  I thought I had the syntax right when I tried it this morning.  I couldn’t get it to work.  Must have needed more coffee.

Thanks!

Bill

Thanks a ton for this, Bill! Is there any way to include text along with the profile/permission set name? I can’t figure it out using the formula.

IF(STARTS_WITH({{{Parent.Name}}},“X”),Profile:{{{ParentNameLookup}}},Permission Set:{{{Parent.Name}}})

Something along the lines of the bolded text above.

Thanks, Amy! 

Josef,

You just need to ‘wrap’ your Then and Else with single quotes:

IF(STARTS_WITH({{{Parent.Name}}},"X"),'Profile: {{{ParentNameLookup}}}','Permission Set: {{{Parent.Name}}}')


Thanks,

Bill

Thanks a lot!