Jump to content
  • 0
Sign in to follow this  
NiceDuck

duplication of child records

Question

Hello everyone,

I would like to share a trigger workflow again. 

I have this workflow in my application where the user will set a work order.  On this work order, the user can now then assign another multiple job orders.  The work order serves as the title or parent while the job orders are the different jobs inside the work order. I have no problem on setting allocated tables and datapages for this.  

The issue is, sometimes, there are new work orders where they just similar to an old work order. So after creating this new work order, you also have to recreate the children of this work order. This can become quite troublesome and annoying because some work orders have 5, 10's or even hundreds of childs and its a lot of work to manually recreate them.

Therefore, I would like to share this solution with you which I achieve by using triggered actions.

first, on my "work_order" table, I added a text field named "work_order_id_origin" 

second, on my submission form for my work orders, I included this field and set its form element as a drop-down. I assign my work order table as its look up table, this now displays the different titles of work orders but has the value of their work_order_id. Make sure to add a blank value to your dropdown so you can still record new work orders.

The reason for this dropdown is for the user to select which previous work orders is this new work order is similar. 

Then on trigger action, The trigger will now check if the value on this field is equal to any id value on work order tables. If it found a match. You will have to use a "IF THEN" block which has the condition of "Select top 1 from #inserted" which contains  value of "#inserted.work_id_origin"  Then use 'in' logical operator then use the query statement "Selec From Work_order_table" which contains the value of "work_order_id". This trigger block is the checker if the desired work order is a copy from previous record or a new one.

On "THEN" part of this conditional statement, You will simply have to use an "Insert Into" where block  select from "Job_order_table"  where its "parent work_order_id" is equal to #inserted's "work_order_origin table". Then reinsert all of those record again with in the same table but this time, with different parent ID. 

You may also change some other field values with this upon re-insert. Hope It helps.

 

QUACK

 

 

 

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi NiceDuck,

It's seems like a nice Workflow. However, as I see it,  you are also using the work order table as the lookup table for this workflow. Also, those new work orders which is actually a clone of an old record will also be considered as a new record. Therefore, in the  Long run, I think this will cause a stress on your data traffic specially when the Work_order table becomes heavily populated. You may not notice that now, but when your records starts to reach hundreds or thousands,  The dropdown button that you assigned to look for previous may cause a huge data spike. 

.... hope that helps

 

Share this post


Link to post
Share on other sites
  • 0

Thank you for your comment Shiro,

I actually have to spend the last few days about that. My workflow may someday cause a data overflow.

As a solution, I think instead of automatically setting up every record as a possible template,  I'm just gonna add a yes/no filed on my work order table and set it up as a checkbox in my Submission form and details page.  This will allow  the user can select which of the current work order records  would became the template and save it into a different table which I'm going to call as "Work order Project templates". 

Here the new trigger that I set.

Thank again for the warning Shiro. I havent said it, It may have cause me a problem later.

 

forum.png

Share this post


Link to post
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...
Sign in to follow this  

×
×
  • Create New...