Reference with valid if causing bot error

Hi, so this is slightly complex but here goes. 

In my app. First , Role 2 or Role 7 will go to "Add New" (Register Role table) view where they will enter the First Name, Last Name, Personal Email, and the Role number of the new user which should ultimately be 5. Role Number is a reference to the Roles table which has ID, Role Number, and Description of Role. I set a valid if constraint on the Role Number on the RRtable that said if lookup(useremail(),Employees, WorkEmail, Role) = "2" Select(Roles[ID], True), List("5"). That way if role 2 adds they have the option on "add new" to choose any role, but any other role tries to add, the only choice will be "5". This worked as expected. Then

New user logs in with Personal Email. They log into home view which has 2 action buttons allowing them to choose employee or contractor. The action starts a new row on the New User table and then shows the forms that need to be downloaded for that choice on the next view. Once theyve downloaded the required forms they are taken to a form view for registration where they fill out the required fields. Once saved, all saves on the same row as they started originally and adds "Submit" to Submit column. Saving triggers the next bot. This will send an embedded app view by email to admin who is Role 2. Admin will press action button approve which will change the submit to approved which triggers the next bot. this bot checks for updates and for Submit to say Approved. It adds a new row to the Employees table and copies the fields from the NU table to appropriate fields in employee table. 
Then it does action on rows in RRtable using reference SELECT(Register Role[Personal Email], [Personal Email] = [_THISROW].[Personal Email]) changing the Role number to 8. Then it changes the Role number on Employee table action on rows using reference SELECT(Employees[ID], [Personal Email] = [_THISROW].[Personal Email]) and the action LOOKUP([_THISROW].[Personal Email], "Register Role", "Personal Email", "Role number") because the Role number in employees should reflect what RRtable says.  Lastly bot deletes the row in NUtable. All works as planned. 

Next bot, for Employees table checks for updates with condition And([Role]="8", ISBLANK([Employer Approved]),[_thisrow_before].[Role]<>[_thisrow_after].[Role]). Sends an embedded app view email to Role 7 where they will check off a few things. First is Region. Region is an enum list with reference to Regions table. valid if constraint of Regions[ID]. It populates correctly in view and also in email, however when multiple regions are chosen, it only captures one of them on database. next they have a few yes or no questions and lastly a choice to approve or decline. if they choose approve, the Employer Approval column on employees table is changed to Approved. This triggers next bot.

This bot checks for updates to employees table and the condition of [Employer Approved]="๐Ÿ‘๐Ÿผ Approve "
The bot will send an embedded app view to admin that allows them to add credentials such as work email, phone, etc and then they press action button of approved that changes the Employer Approved column to Yes. This triggers next bot where I have the next problem. 

This bot checks for updates with condtion that employer approved says Yes. Then it runs action on rows in RRtable using reference SELECT(Register Role[Personal Email], [Personal Email] = [_THISROW].[Personal Email]). The action changes the Role Number to "1". then it changes the role number on employees table by setting row values and changing Role Number to LOOKUP([_THISROW].[Personal Email], "Register Role", "Personal Email", "Role number"). Lastly it changes the Employer Aprroved column to "Finalized". 

The bot is throwing an error of Error encountered in step with name [change user on register role]: Error: Perform DataAction 'change to user 2' failed because Row having key 'user@gmail.com' in table 'Register Role' containing value '1' in field 'Role number' failed 'Valid_If' condition. 
I tried changing the constraint to lookup(useremail(),Employees, WorkEmail, Role) = "7", list("5"), Select(Roles[ID],True). same error, changed to just Roles[ID] same error. Only worked when i removed the constraint completely.

Sooo...is there a way to have the constraint so that the role 7 can only choose 5 and anyone else can choose anything else without throwing throwing the bot off in only that last section? I can't understand what is causing the issue. especially when it works for the earlier bot. And does anyone know how to get all values chosen in the embedded app view with enum list in my column instead of only capturing 1? I should add that all of the embedded app views are detail view with editable columns rather than forms. 
 

0 2 51
2 REPLIES 2

One option if bots are ever causing issues with Valid Ifs it to change your valid if condition to be OR(CONTEXT('Host')='Server',Insert Previous Condition HERE). That will make it so that it is always true when working with a bot. You are likely running into issues where the person who is triggering the bot does not have access to change to that role which is why it is erroring out, using context should make it work every single time for bots.

@Alyssa_QREW I would totally agree except I am the one triggering and i'm role 2 which is the role allowed to do so. I even added a virtual column to show what the Role Number was of useremail just in case and it shows the correct role number. i'll look at what you said though. maybe giving that extra context will help despite the correct role. 

Update: I tried this and a few other ways because OR threw an error bc/y/n so tried in other ways and it didn't work. Still threw bot error.

Top Labels in this Space