Hi All, I need some urgent help with a Valid_If statement please.
I have a Parent Table for Orders. And I have a Linked Child Table for Order_Items.
The Parent Orders Table has a “Order_Status” Ref dropdown to select the Status of the Parent Order and the Child Order_Items table has a “Order_Item_Status” Ref dropdown to select the status of each of the Individual Order_Items.
I don’t want the User to be able to select the Parent Order_Status - “Closed - Complete” or “Closed - Cancelled” If there is an existing Child Order_Items record with an Order_Item_Status “At Bending” or “At Welding” etc..
Only if all the Child Order_Items linked to the Parent Order have a status of “Packed - Complete” or “Cancelled” must the User be allowed to select the Parent Order_Status “Closed - Complete” or “Closed - Cancelled”.
The Parent Table (Orders) has a Key [SO_Number] (Text)
and the Child Table (Order_Items) has a Key [SO_Item_Id] (Unique ID)
and the Child Table (Order_Items) has a [SO_Number] Ref Column to the Parent Table (Is Part Of)
It might be easier (meaning a simpler expression) to check that none of the order items are in status other than those two rather than checking if they all are.
ISBLANK(
INTERSECT(
LIST(a list of all possible status) - LIST("Packed - Complete", "Cancelled),
[related Ordered Items][Status]
)
)
Here if you maintain all possible status in a table, say Order Item Status, (a list of all possible states) can be Order Item Status[state] or just write them out one by one.
You have somewhat different descriptions for those two statuses in the parent and child table, or else @TeeSee1 's suggestion is very good to try as a compact one.
Since you have somewhat different descriptions, your valid_if in the parent table can be something like below. It is somewhat longish. Will try to see if it can be reduced.
Thanks I tried that but then there is only 1 Status available to choose from on the Parent (Orders) dropdown. I have reworded my original post to try and make more sense of what I need. See below.
Hi All, I need some urgent help with a Valid_If statement please.
I have a Parent Table for Orders. And I have a Linked Child Table for Order_Items.
The Parent Orders Table has a “Order_Status” Ref dropdown to select the Status of the Parent Order and the Child Order_Items table has a “Order_Item_Status” Ref dropdown to select the status of each of the Individual Order_Items.
I don’t want the User to be able to select the Parent Order_Status - “Closed - Complete” or “Closed - Cancelled” If there is an existing Child Order_Items record with an Order_Item_Status “At Bending” or “At Welding” etc..
Only if all the Child Order_Items linked to the Parent Order have a status of “Packed - Complete” or “Cancelled” must the User be allowed to select the Parent Order_Status “Closed - Complete” or “Closed - Cancelled”.
The Parent Table (Orders) has a Key [SO_Number] (Text)
and the Child Table (Order_Items) has a Key [SO_Item_Id] (Unique ID)
and the Child Table (Order_Items) has a [SO_Number] Ref Column to the Parent Table (Is Part Of)
In Valid-If, you have to test not only the status of the related ordered items but also what you choose in the parent’s status it self. So the expression should be something like
IF(
"are all related ordered items completed or cancelled", LIST("Closed - Complete", "Cancelled",
LIST(here is all the rest of allowed status)
)
to return a list of allowed values depending on the status of the related ordered items.
The expression I proposed was for the “are all related ordered items completed or cancelled” part.
Thank you for additional details. No, that is not a list expression. It is a reference column and the list displays due to the nature of the ref column. But your additional information does help to suggest an expression. You may want to try the below expression
Order_Status[Key Column]- LIST( “Key column value of Closed - Complete status record in the Order_Status table” , “Key column value of Closed - Cancelled status record in the Order_Status table” ))
)
Edit: Made some changes to the suggested expression above.