Jump to content
  • 0

Triggers on bulk updates to insert multiple records on a second table



I have some confusion about how triggers work on bulk updetes. 
My thought was that an update Trigger should start for each selected record in the bulk update, but this is wrong. I see that some actions are performed on the whole set of selected records and som other only on the first.

The only place where I found this explained is here https://caspio.uservoice.com/forums/164206-caspio-bridge/suggestions/34321655-triggered-actions-on-update-fired-on-bulk-edit-u 
where @TonyS says that 


Triggered Action is working with the whole scope of changed data at once. This means that any of the action in the trigger will be applied to the whole scope of data (not record-by-record) and will be fired only once per bulk update.

My questions are:

  1. Is this the real trigger's behaviour? There is some doc/help where I can learn more? It doesn't seem to me that the help at https://howto.caspio.com/tables-and-views/triggered-actions/  mention it, I am wrong?
  2. As result of bulk edit on table_a, how I can insert multiple records on a table_B (one for each record included in the bulk operation)?
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @vidierre,

I am not sure I understood the question correctly, however, I can say that, when using the Triggered Action as shown in the image below,  I could use Update Bulk in the Report DataPage to update multiple records. I have two Tables. Table 1 and Table 2. I have set up The trigger on the Table 1 to Update table 2.

In my case if I set value for orders 10, both records will get records 10.




Link to comment
Share on other sites

  • 0

Hi @RagnarIllyrian, this is not my scenario, because I need to perform several INSERT on a table each with different data from records selected with the bulk function.

I have:

  • Table_students with students data and two fields, one Yes/no named student_to_enroll  and a second Text named class_to_enroll
  • Table_courses with courses data
  • Table_subscriptions that has only two fields student_id (from Table_A) and course_id (from Table_B)
  • View_subsriptions that is made joining the three tables and allowing changes to Table_students

Then a report datapage of  View_subscriptios   where course_id is received as input from an external parameter [@id]. This is the course_id of the class where studens are to be enrolled. I use this parameter to perform two things:

  • Filter the data for all records tha NOT contains the id. In this way I see all tudents not enrolled to the course
  • Use the ID, with the student_id, to INSERT recors into Table_subscriptions 

I was trying to perform the bulk update action showing a dummy form where student_to enroll and class_to_enroll are hidden and initialized with Yes the first and [@ID] the second.

In the trigger I was hoping to insert a new record in Table_subscriptions for each selected students with theirs student_id and [@ID] (that is the course_id to enroll each student).
But, even if mor than one record is selected only one record is inserted into the Table_subscription confirming that triggers is triggered once considering the whole set of bulk selected redords instead to be trigged for each change.

My feel is that I have to chenge my mind and build something different.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...