List of Editors

Hello,

I would like to create the table with list of approved editors for my app, and than on the base on user email to let the user edit or just read only. My idea is to create “Editors” table just with “Mail” column and to use code to check if user email is on Editors table and than add proper access.
The code :
SWITCH(USEREMAIL(),
LOOKUP( “USEREMAIL()” , “Editors” , “Mail” , “Mail” ), “UPDATES_ONLY”,
“READ_ONLY”)
Still not working :wink: but do you thing it is a good idea or is it better to do it other way?

Try something like…
IF(
IN(USEREMAIL(),Editors[Mail]),
“UPDATES_ONLY”,
“READ_ONLY”
)

2 Likes

@Aleksi’s suggestion is a good one.

The reason your expression didn’t work is because you enclosed USEREMAIL() within quotes in your LOOKUP() expression:

LOOKUP( “USEREMAIL()” , “Editors” , “Mail” , “Mail” )

As a result, LOOKUP() was looking for the literal text, USEREMAIL(), rather than for the current user’s email. Had you instead used:

LOOKUP( USEREMAIL() , “Editors” , “Mail” , “Mail” )

without the quotes around USEREMAIL(), it likely would have worked fine.

3 Likes

Thanks both @Aleksi and @Steve both suggestions work perfectly, and I even prefer one from @Aleksi better than my first idea!

1 Like

Hello another step… can I nest IFs in this expression? I tried sth like this, and it does not work:

IF: (IN(USEREMAIL(),Experts[ExpertMail]),
“ALL_CHANGES”,
IF(IN(USEREMAIL(),Editors[EditorMail]),
“ADDS_ONLY”,
“READ_ONLY”)
,“READ_ONLY”)

Try this instead:

IF(
  IN(USEREMAIL(), Experts[ExpertMail]),
  “ALL_CHANGES”,
  IF(
    IN(USEREMAIL(), Editors[EditorMail]),
    “ADDS_ONLY”,
    “READ_ONLY”
  )
)

Or this:

IFS(
  IN(USEREMAIL(), Experts[ExpertMail]),
    “ALL_CHANGES”,
  IN(USEREMAIL(), Editors[EditorMail]),
    “ADDS_ONLY”,
  TRUE,
    “READ_ONLY”
)

See also:




2 Likes

Thanks a lot, worked perfectly as usual!
I have read above but somehow got lost in nesting - my experience in coding is close to zero :slight_smile:

1 Like