Are Updates Allowed? rule not working

Iโ€™m using the following as an Are Updates Allowed? rule:

IF(
	OR(
		IN("Manager",INDEX(CURRENT_User[Type],1)),
		IN("Admin",INDEX(CURRENT_User[Type],1))
	),"ADDS_AND_UPDATES",
IF(
	ISBLANK(UserEmail()),"ALL_CHANGES",
	"READ_ONLY"
))

but when I try to edit a record I get:

Table 'Plot' does not allow this operation. Expression result: 
'READ_ONLY'. 
Expression Trace: 
{"key": "IF(OR(IN(\"Manager\",INDEX(CURRENT_User[Type],1)), IN(\"Admin\",INDEX(CURRENT_User[Type],1))),\"ADDS_AND_UPDATES\",IF(ISBLANK(USEREMAIL()),\"ALL_CHANGES\",\"READ_ONLY\"))","result": "READ_ONLY","values": []}

CURRENT_User is simply a slice to not have to use ANY(Select(โ€ฆ multiple times

Iโ€™ve tested the formula in UserSettings and as a whole I get a result of โ€œADDS_AND_UPDATESโ€ and INDEX(CURRENT_User[Type],1)) gives me โ€œAdminโ€.

So Iโ€™m a bit stuck as to how its clearly getting โ€œREAD_ONLYโ€ at the table level

Solved Solved
0 23 216
1 ACCEPTED SOLUTION

CONCATENATE() should help

View solution in original post

23 REPLIES 23

3X_7_1_710b5d843004194b65f9dc6dabb7b01502c282ab.png

Iโ€™m surprised itโ€™s not returning an error. The second argument of IN() should be a List, INDEX returns a single value.

Is [Type] EnumList?

If [TYPE] is Enum

IFS(
  INDEX(CURRENT_USER[TYPE], 1) = "Manager", "ADDS_AND_UPDATES",
  INDEX(CURRENT_USER[TYPE], 1) = "Admin", "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

If [TYPE] is EnumList

IFS(
  IN("Manager", SPLIT(CURRENT_USER[TYPE], " , "), "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(CURRENT_USER[TYPE], " , "), "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

Yeah, sorry [Type] is a ENUMLIST

Though you maybe onto something. For my record it only returns โ€œAdminโ€. Iโ€™ll see what happens if there is more than 1 item in [Type]

Nope doesnโ€™t work if [Type]=โ€œAdmin,Managerโ€

Iโ€™ll try @SkrOYC suggestion

Check your EnumList config so that the Item Separator is configured as default
" , " (space - comma - space) to prevent problems in the future

Item seperator was missing. Added comma. Made no difference.

Make sure item separator is exactly Space - Comma - Space
Also the values on Type column inside the database should be this way:
Admin , Manager
Instead of
Admin, Manager or Admin,Manager
Just make sure the item separador is the string between the first and the second option

Well, if youโ€™re just going to use SPLIT(), maybe not.

Then

IFS(
  IN("Manager", SPLIT(CONCATENATE(CURRENT_USER[TYPE]), " , "),
    "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(CONCATENATE(CURRENT_USER[TYPE]), " , "),
    "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()),
    "ALL_CHANGES",
  0=0,
    "READ_ONLY"
)

IFS(
  IN("Manager", SPLIT(CURRENT_USER[TYPE], " , ")), "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(CURRENT_USER[TYPE], " , ")), "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

No Edit Button

IFS(
  IN("Manager", SPLIT(INDEX(CURRENT_USER[TYPE],1)," , ")), "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(INDEX(CURRENT_USER[TYPE],1)," , ")), "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

No Edit Button

Tested IN(โ€œAdminโ€, SPLIT(INDEX(CURRENT_USER[TYPE],1),",")) as a UserSettings formula. Result was TRUE

CONCATENATE() should help

IFS(
  IN("Manager", SPLIT(CONCATENATE(CURRENT_USER[TYPE]), " , ")), "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(CONCATENATE(CURRENT_USER[TYPE]), " , ")), "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

Works. Totally not intuitive. But it works. Thanks @SkrOYC

Also love the

0=0, "READ_ONLY"

to give an IFS() a default condition. Definately be nicking that one

@1minManager

Why not just use IF()???


Iโ€™m weary of the 0=0 statement - which is always true.

  • What happens if things donโ€™t process linearly like weโ€™re expecting?

They invented Bug Reports for that

@MultiTech_Visions Iโ€™m thinking more of a solution where youโ€™ve got a formula with 5-10 nested IF()'s. Using an ISF() with this last row just looks neater. Appreciate its not more functional

3X_1_8_1839f070ec1159211a557666c47e626525932410.png

Thatโ€™s the magic of CONCATENATE()
It solves all the mess that we could have made inside Item Separator and help SPLIT() make itโ€™s job

IFS(
  IN("Manager", SPLIT(CURRENT_USER[TYPE], " , ")), "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(CURRENT_USER[TYPE], " , ")), "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

No edit button

  IN("Manager", SPLIT(INDEX(CURRENT_USER[TYPE],1),",")), "ADDS_AND_UPDATES",
  IN("Admin", SPLIT(INDEX(CURRENT_USER[TYPE],1),",")), "ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()), "ALL_CHANGES",
  0=0, "READ_ONLY"
)

Same error message

  IN("Manager", LIST(INDEX(CURRENT_USER[TYPE],1))),"ADDS_AND_UPDATES",
  IN("Admin", LIST(INDEX(CURRENT_USER[TYPE],1))),"ADDS_AND_UPDATES",
  ISBLANK(USEREMAIL()),"ALL_CHANGES",
  0=0, "READ_ONLY"
)

No edit button

Odd thing is, why if I can see the edit button, I canโ€™t edit a record. When the rule is supposed to apply to the entire table?

Aurelien
Google Developer Expert
Google Developer Expert

@1minManager
I suspect this is related to this kind of situation

Would

IFS(
...
TRUE, "READ_ONLY"
)

not work just as well?

Yep, it should.
I do logic (0=0, 1=1 | 0<>0, 1<>1) because my main language is Spanish and the True, Verdadero, Yes, Sรญ, is a little bit messy.
Logic stuff is better from my POV since the platform decides how the hell it wants to save the value in the database while I get the results.
For example, I use โ€œTrueโ€ as Initial Value and the platform saves that as โ€œVerdaderoโ€. Itโ€™s counterintuitive. I preffer logic in this case

Top Labels in this Space