Actions

Dear, I have a query.
I have a table A in which, when generating a new record, I have an event associated with saving the form that creates a new row with some of the data in table B. The problem I'm having is that when updating the record in table A (which has already created a record with part of this data in table B, including the reference ID of the record from table A), the action recreates another row (record) with the updated data, which is not desired since a single reference record to table A must be maintained. How can I solve this?

0 8 214
8 REPLIES 8

In the action's condition setting ( "Only if this condition is true" setting) , please enter an expression something like 

AND( ISBLANK( [Related table B records]), MAXROW( "Table A" , "_ROWNUMBER") = [Key column of Table A] )

where [Related Table B Records] is the reverse reference column in table A

Edit: made changes to the suggested expression to make it more failsafe.

This expression will prevent the row being added to table B in most cases once the record in table A is created, but could possibly fail in multiuser environment. Another condition addition such as [Email] column of the person who adds the row, if it is available in the table A , then that can be used in the expression to make it more failsafe.

AND( ISBLANK( [Related table B records]),  MAXROW( "Table A" , "_ROWNUMBER", [Email]=USEREMAIL()) = [Key column of Table A] )

Edit: made changes to the suggested expression to make it more failsafe.

Thank you very much for your reply.
I have been able to solve so that it does not create a new record in table B when it has already been created previously. The problem is that when I update the record in table A, I won't be able to get the data in table B to be updated, since it will be static from the first time I save the record in table A.
In order not to add another new row when there is already a previously created one, use this expression ( "Only if this condition is true" setting) and it worked.
AND(
OR([Risk Level] = "2", [Risk Level] = "3"),
ISBLANK(
FILTER(
"Risk Notices",
([Reference ID] = [_THISROW].[UNIQUE ID])
)
)
)
The problem I'm experiencing is that I can't update the fields in table B that come from the record in table A when I do an update here.

So is it the correct understanding that 

1. You would like to add a row to table B automatically when you add a new row to table A

2. You would like to prevent addition of new row to table B when an existing record in table A is edited.

3. However you would like to change the values of some columns in the related record of table B  that is already created in step 1 above, when the corresponding parent record A is later edited.

Right, that's exactly what I want to achieve.

Thank you. I think you have already achieved points 1 and 2 from above.

For point 3 ,

A. Please create a reference action ( Action type: Execute an action on a set of rows) on table A that references rows of table B with a reference row expression something like 

[Related Table B Records]

where [Related Table B Records] is the reverse reference column in table A

Edit: Made the referenced rows expression more economical by using system generated column.

B. In the referenced action of type:  set values of some columns in this row on table B, change the column values in the table B that you want to change when the table A row is edited.

C. Make this action created in step B as referenced action of reference action created in step A

D. Create a group action on table A that has first action as 

       a) Add new row to table B that you have already created

       b) The second group action can be the reference action you have created in step A above

Edit: Please revert if you have any queries or your updates.

Dear, thank you for your answer, I have several doubts regarding what you propose.

I currently have an action created in the "Sling Control" table that adds a row to the "Risk Notices" table with some values from the "Sling Control" table.
The "Risk Notices" table is nourished by multiple controls such as the one in the "Sling Control" table, for example, I have identical actions that generate another row in "Risk Notices" from "Board Control", "Crane bridge control ", "Accidents and incidents"... all these tables send information to the fields established in "Risk Notices".
add_row_to_AvisosDeRiesgo.jpg

The table "Risk Warnings" has the only reference to the tables that feed it is a column called "Reference ID" which is the "UNIQUE ID" of the tables "Control de Ligas", "Control de gantry crane", "Accidents and incidents", as well as all the tables that send information to the "Risk notices". So there is no system relational column between tables. Well, it feeds on multiple tables.
I have created the second action that you propose in step A, in this way:
edit_action.jpg

Now in step B I think that I am not managing to understand it or maybe because of the way in which I have articulated the project I cannot do this action.

this action "B. In the referenced action of type: set values of some columns in this row on table B, change the column values in the table B that you want to change when the table A row is edited."

Where should I create it in table B "Risk Notices"?? How do I connect it to the actions of table A "Sling Control"...because they are different tables with no relation.

I remain attentive to your suggestions. Thank you very much for your time.

Thank you very much @Msant77s  for the detailed information.

May I say that the information you have provided in the latest post could have been furnished in the first post itself with more details of the columns etc.  I will request to provide a detailed enough information for such tricky requirements to start with.

The initial request started with just one requirement


@Msant77s wrote:

the action recreates another row (record) with the updated data, which is not desired since a single reference record to table A must be maintained.


The second post mentioned the following additional point


@Msant77s wrote:

The problem I'm experiencing is that I can't update the fields in table B that come from the record in table A when I do an update here.


The third post mentions many additional points


@Msant77s wrote:

I have identical actions that generate another row in "Risk Notices" from "Board Control", "Crane bridge control ", "Accidents and incidents"... all these tables send information to the fields established in "Risk Notices".


This is a totally additional and different information. As we can imagine, the approach proposed will depend on the information given in the query.  While I have not fully understood the latest information you have given, I am afraid the earlier mentioned approach may not work with this significant additional information.

Coming back to the latest information, may I request you to 

1. Clarify if the table "Risk Warnings" and "Risk Notices" are different or the same?

2. Could you update with the screenshots of the relevant columns of the tables  "Sling Control"  , "Risk Warnings" and "Risk Notices" and what you are trying to achieve with these 3 tables?  And how other tables are adding rows to the "Risk Notices" table and why you feel it could have impact on the current functionality.

 

In the meantime my current response based on the current understanding  is as follows.

The current understanding also assumes that Risk Notices table is child table of Sling Control table.

.

 


@Msant77s wrote:

Where should I create it in table B "Risk Notices"?? How do I connect it to the actions of table A "Sling Control"...because they are different tables with no relation.


These are basically reference actions.

Please take a look at the sample app and its description under Info --> Properties -- > App Documentation to understand the reference actions.

Reference Actions - AppSheet

 

Your action A can be something like belowAction A.png

 

Your action B can be something like below: 

 

Action B.png

Sir, thank you for your answer, I will analyze it in these days. I'll give you an answer as soon as I can.
Thanks for your time

Top Labels in this Space