Jump to content
  • 0

Update trigger to insert multiple records based on Quantity field in #insert


JohnNuttDesk

Question

Hi Hi

I need to print a label for each item that I sold.  For example, in my SalesDetail table, I have one record that I sold Quantity = 14 of item AAA and a 2nd record that I sold Quantity = 3 of item BBB.  I need 14 records of item AAA Inserted to my Shipping Label table and I also need 3 records of item BBB Inserted as well.   I have a datapage that can then print 17 beautiful labels.  My trigger below works great on Update if I only Update one record at a time in Sales Detail.  The problem is that I have 100s of records in Sales Detail and I "Bulk Edit" the records.   The trigger below will either pick the 3 OR the 14 and then, for example, Insert 3 records of AAA and 3 records of BBB.  Do I need to use the "For Each Record In" Loop?  I added the TxnLineId which is unique to each record in SalesDetail but I still couldn't fix my problem.  Help is always appreciated!

 

image.png.082cafb6f765083cb5281f09c0e733f8.png

image.png.5aebfd51ec31475ab18b4489cda291ad.png 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Caspio was able to help with the answer.  Here it is.  This trigger will make/Insert "x" number of records in the "child" table based on the "x" number in the quantity field of the parent.  Most importantly, it works in bulk edit mode on the parent table as well.  For example, I can update a "batch #" like 123 into the batch field of my parent table.  I can use  the Bulk edit to update dozens of records with this "batch" number 123.  Then this trigger will insert multiple child records for each parent record updated with the batch #.  For example if one record in the Parent has the quantity set to 15 then this trigger will create 15 records in the child table.  Great for making shipping labels!!  

 

image.png.d2fcb832940f7e3ffc2da6f9257fe419.png

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.

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

Loading...
×
×
  • Create New...