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.

  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.
1 Like

@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-3d26-475c-a8f8-9911f5015920

1 Like

@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]”

1 Like

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).

2 Likes

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 !

1 Like