Change value of a column in a table when form is submitted in another table

I am creating a basic CRM for internal use.

I have a table โ€œorganizationsโ€, containing the columns [organization name], [stage], plus others which are not important

Than I have a table โ€œprojectsโ€, containing the columns [organization name], plus others plus others which are not important

The column [stage] in table โ€œorganizationsโ€ is displayed as dropdown with fixed predefined values:
Cold Lead
Contacted
Interested
Call Scheduled
Pilot Project
Project

What I would like is that whenever I submit (the form view) of the table โ€œprojectsโ€, it should, of course, first of all add the new row in the table, as usual, but also change the value of the column [stage] in the โ€œorganizationsโ€ table to โ€œProjectโ€, from whatever it was before.

The form view of table โ€œprojectsโ€ will have the [organization name] displayed as dropdown, and the choices will be the values of the column [organization name] from the table โ€œorganizationsโ€.

NOTES:

  • I know how to dynamically populate dropdowns with data from other columns
  • The column [organization name] in table โ€œprojectsโ€ will be a REF type, (displayed as dropdown), and will be refferencing [organization anme] in โ€œorganizationsโ€; this raises an additional question, whether this column should also be marked as โ€œis part ofโ€ or notโ€ฆ

Looking forward to your answers, and please let me know if you need additional details.

Solved Solved
0 11 1,907
1 ACCEPTED SOLUTION

Sure you can. You can create a workflow that runs only upon Deletes, which triggers the actions to run. Or you can replace the system-generated Delete action with one that is a grouped action (although keep in mind there may be other ways that a record could get deleted, and thus wouldnโ€™t trigger everything you want).

View solution in original post

11 REPLIES 11

  1. Make an action for the Organization table that changes the column value.
  2. Make an action for the Project table that is a โ€œreference actionโ€, its called โ€œdata: execute an action on a series of rowsโ€ in the editor. Use the [organization name] column as the referenced rows.
  3. Set the action to run upon saving of the form, find that option under Behavior section in UX.

@Marc_Dillon

  1. Completed, but what purpose does it have? What is the โ€œtriggerโ€?
  2. I canโ€™t choose the [organization name] column as referenced rows; error displayed: โ€œThe expression is valid but its result type โ€˜Nameโ€™ is not one of the expected types: Listโ€

From what I know, a list type is only good for virtual columns, so of course my [organization name] column in โ€œorganizationsโ€ table is a name type

If thereโ€™s something fundamentally wrong with my logic, I apologize, Iโ€™m quite new to appsheet.

Oh right. Weโ€™ll just convert organization name to a single item list. Use LIST([organization name]) as the Referenced Rows. As far as the trigger for #1, youโ€™ll select the action in the specification of action #2.

Hereโ€™s a sample
https://www.appsheet.com/samples/This-app-shows-how-to-use-reference-actions?appGuidString=e76d2e73-...

@Marc_Dillon

It works (with a slight adjustment), thank you so much!

For other users who might be interested in this:

Use LIST([organization name]) as the Referenced Rows.

I DIDN"T have to, because I was actually making a mistake and writing just โ€œ[organization name] in the expression field, instead of organizations[organization name]โ€

organizations[organization name] is going to give a list of ALL records in the organization table, and thus the action will run on ALL of them. I donโ€™t think this is what you want, I think you want LIST([organization name]). That will return the single organization record referenced by the project record that you are modifying.

you are absolutely right! Iโ€™ve changed accordingly, ( after having to edit my entire sample data :)) ), now all looks good!

@Marc_Dillon

To make this even more useful, could I also change the value of [stage] to something else if the project created earlier is deleted?

Sure you can. You can create a workflow that runs only upon Deletes, which triggers the actions to run. Or you can replace the system-generated Delete action with one that is a grouped action (although keep in mind there may be other ways that a record could get deleted, and thus wouldnโ€™t trigger everything you want).

Well, Iโ€™ve tried it, but I need an action to have effects on table โ€œorganizationsโ€, but be โ€œtriggeredโ€ when a row is deleted in table โ€œprojectsโ€.

When I try creating the workflow, I can only add actions created under the target data table, which, in my case, is โ€œprojectsโ€. However, the action I need is created under table โ€œorganizationsโ€, so I canโ€™t find it & add it to the workflowโ€ฆ

Solved, I was able to find the actions after saving the changes to the app. Thanks again for your help !

Dear all;

Iโ€™m having the same difficulty Cristian had.
One table is called Expediรงรฃo and the other is Pedido. Both of them have a common named column, ( Expedido).

The table [Expediรงรฃo] pulls the ref of the orders (Nรบmero do Pedido) from the table [Pedidos], and creates a dispatch form, with the amount of each item dispatched, the time it was dispatched, amongst other informations.

What Iโ€™m trying to do is to reference the (Expedido) column of the [Expediรงรฃo] table to the (Expedido) column of the [Pedido] table.

What Iโ€™ve got so far:

I have created an action, in which it changes the value of the column (Expedido) in the [Pedido] table, but Iโ€™m not sure how to create the reference between the sales order ( Nรบmero do Pedido), which is the reference number for the sales order.

Thank you all for the support.

Regards,

Fรกbio Nabuco Correia

Top Labels in this Space