Skip to main content

Hi, we have a table where we want to be able to duplicate an existing row because this will streamline our process further.

We have a field called po_number, which is being filled with a trigger. We add a counter to it which makes the record unique. However, when we duplicate an order with the same details, we want a new counter to be assigned to it, but it grabs the old counter and we can't save the record. 

When we duplicate, can we set that value to 0 so that the trigger applies a new counter?

Hi Niels,

While it is not entirely clear on what you are trying to achieve, I think I might know where you want to go. Probably the solution lies within the trigger itself, since that is also the functionality that generates the number.

It might work when you are deciding the new value from the copied record, that a query also determines if there are other rows with the same details. If you want to reset your identity/counter within the table, that is not recommended.

If this process is repeating for most situations, you might want to work with revisions and generate this within a task rather than the trigger. 

Hope this helps and don't hesitate to clarify a bit further if anything is unclear! 


Hi, we have a table where we want to be able to duplicate an existing row because this will streamline our process further.

We have a field called po_number, which is being filled with a trigger. We add a counter to it which makes the record unique. However, when we duplicate an order with the same details, we want a new counter to be assigned to it, but it grabs the old counter and we can't save the record. 

When we duplicate, can we set that value to 0 so that the trigger applies a new counter?

Without knowing your scenario and existing functionality it's a bit hard to steer into the right direction. However if it's something that ‘always’ happens under certain conditions. you could cross join 2 values to the ‘inserted’ table to have the original and the copy like cross join (values(‘original’),('copy’)) oc (type)  then it shouldn't be to hard to let the counter include the copy with for example a row_number() over() or dense_rank() over()


@Niels Koop As the other responses already mention, it is not entirely known what you use to create this duplicate, but here a suggestion as well.

You can disable the “Copy” action in the GUI take over the current value of “po_order”. Navigate from the menu: “Subject” → Specific table/view → “Columns”

Disable “Include in copy”:
 

 


And to add to that ​@Niels Koop you really shouldn't want to pursuit a 'double’ trigger or chain, just to have it noted :)


Reply