Hide Add action if user's reply already exists


Hello, I'm trying to hide the system generated "Add" action button if the current user has already responded to a topic in a thread. The view below is the inline "related replies" shown from a random initial topic. The Avatars on the right are the [Repliers] reference from a [Users] table with email as Key and the avatar as label. "Replies" 1 and 2 are values from [Reply] in the current "Replies" table. 

 Hide Add.png

I've tried different approaches and the following seems to be the closest but it hides the "Add" button altogether without the set conditions. The expression shows no errors:

ISBLANK(
FILTER(
"Replies",
OR(
(LIST[_THISROW].[Reply] = " "),
(LIST[_THISROW].[Replier] <> useremail())
           )
      )
)

I found the expression online to a related topic and tried to customize it to my situation. Maybe I'm getting my logic mixed up, but the idea is twofold: (1) show the Add button if there are no replies and (2) show it if the current [replier] has NOT already replied. 

Appreciate any and all feedback. 

Solved Solved
0 10 222
1 ACCEPTED SOLUTION

I tried all the options offered here but for some reason, hiding the ADD button through an action seems impossible. @Marc_Dillon's solution is interesting but appears to be a bit much for me for this small task. Maybe I'm not good enough to apply it with limited input.

The good news is I found an alternative that I'd like to share. Through the "Valid If" section I was able to find the following expression to warn the user that their input already exists. Therefore, they are not able to add additional comments when they hit "save". 

Not(In([_THIS], SELECT(RepliesTable[Replier], [Comments_ID] = [_ThisRow].[Comments_ID])))

The idea is to compare a new reply to the  comments ID which is also referenced in CommentsTable [Comments_ID]. It seems to be simple enough and works. I'm using it on similar areas as an alternative to hiding the ADD button. Hopefully it makes sense.

Thanks for all the help here and sorry for the delay in responding. 

View solution in original post

10 REPLIES 10

NOT(IN(USEREMAIL(), [Related Replies][Replier]))

The [Related Replies] are from the "Topics" Table and [Replier] is in the current table "Replies" where I'm trying to hide the "Add" button. so I adjusted your expression like this:

NOT(IN(USEREMAIL(), Topics[Related Replies], Replies[Replier]))

But I get this error: IN function is used incorrectly

Is there something else I should be considering? Hope the logic makes sense... Thanks. 

Sorry, same error. 

Aurelien
Google Developer Expert
Google Developer Expert

Hi @dreamerdan 

Using @dbaum 's suggestion and your initial expression:

1) in the TOPIC table, please add a virtual column "Related Repliers"

[Related Replies][Replier]

2) then, use this expression in the ADD button behavior:

NOT(IN(USEREMAIL(), [Topic ID].[Related Repliers]))

Hi @Aurelien

NOT(IN(USEREMAIL(), Topics[Related Repliers]))

No errors, but the "Add" button is still there. Strangely, it's hidden if I remove the "NOT(" in the expression. But either way it doesn't seem to be responding to the condition set in the Action "Replies" behavior area.  

You have [Topics ID] but it's either [Topics] or [ID] .[Related Repliers] right? Either case it doesn't seem to be responding. 

 


@dreamerdan wrote:

You have [Topics ID] but it's either [Topics] or [ID] .[Related Repliers] right? Either case it doesn't seem to be responding. 


 

I meant the columns with type Ref that refers to your current Topic (the one you have on your screnshot).

What about this ? Without knowing your table structure, this is just a guess.

NOT(IN(USEREMAIL(), [Topics].[Related Repliers]))

 

You can't conditionally hide the add button like that. What you need to do is setup a read-only Slice (or at least add-disabled) of the related table, add a new REF_ROWS VC, and conditionally hide/show those 2 REF_ROWS VCs with opposing conditions.


@Marc_Dillon wrote:

You can't conditionally hide the add button like that.


Really ? 

I agree with you on the method (this is the one I use to use), but I was not aware of such limitation.

@dreamerdan sample app for @Marc_Dillon 's method:

PF_Restrict_InlineAdd

I tried all the options offered here but for some reason, hiding the ADD button through an action seems impossible. @Marc_Dillon's solution is interesting but appears to be a bit much for me for this small task. Maybe I'm not good enough to apply it with limited input.

The good news is I found an alternative that I'd like to share. Through the "Valid If" section I was able to find the following expression to warn the user that their input already exists. Therefore, they are not able to add additional comments when they hit "save". 

Not(In([_THIS], SELECT(RepliesTable[Replier], [Comments_ID] = [_ThisRow].[Comments_ID])))

The idea is to compare a new reply to the  comments ID which is also referenced in CommentsTable [Comments_ID]. It seems to be simple enough and works. I'm using it on similar areas as an alternative to hiding the ADD button. Hopefully it makes sense.

Thanks for all the help here and sorry for the delay in responding. 

Top Labels in this Space