DMXzone Server Connect Support Product Page

Under investigation

Insert always adds two records

Reported 22 Mar 2016 22:31:41
1
has this problem
22 Mar 2016 22:31:41 Brad Lawryk posted:
I have an insert which I did manage to get working but it inserts two records. I have it in the same Action as an update. So with one submit it updates info in one form and inserts into another. Is this the cause and if so, how do you get it to only add one record?

Replies

Replied 22 Mar 2016 22:53:49
22 Mar 2016 22:53:49 Teodor Kuduschiev replied:
Hi Brad,
How are you filtering your update record?
If both db procedures are into a same action file, using a same form, and both run on submit, this may be causing the issue.
It is possible to have insert and update in a single action file, and on the same form on submit, but there must be a condition, which switches between them. This condition may be a query, a url parameter check etc. Example Action Steps for such a check:
1. DB Query - check if record exists
Condition - if record exists
- THEN - Update
- ELSE - Insert
So the action executor will only run one of them, depending on this.
Or maybe:
2. URL Var Filter, used for the update record step
Condition - if $URL.VariableName exists
- THEN - Update
- ELSE - Insert

Please explain what is your case, so i can advise you how to proceed with that.
Replied 22 Mar 2016 23:01:49
22 Mar 2016 23:01:49 Brad Lawryk replied:
In My case I have a form that needs to update an existing record (this works) but it also has to add a new record in a different table (this also works but adds record twice).

So I tried splitting it and doing it as two actions tied to the same button. For example I added behaviours to first run the insert and then a second action to do the update. (This also works but still has the same problem of two inserts.)

So a then/else wouldn't work as I need both of them to run every time.

I can't see what is triggering the second insert.
Replied 22 Mar 2016 23:09:02
22 Mar 2016 23:09:02 Teodor Kuduschiev replied:
Then the proper thing to do is to have them in one action file, using the same trigger method, say on form submit.
Then you will have the action file like:

- DB Connection
- Update Record
- Insert Record

If this is what you have, and it is still inserting two records, please send us a link to this page, where we can check what is wrong.
Replied 22 Mar 2016 23:15:43
22 Mar 2016 23:15:43 Brad Lawryk replied:
That is exactly how I have it set up. I can't send a link though as it is in a secure area with sensitive data. At least I know I was doing it right so I may have to look at a different method. Maybe you guys can add a tutorial for this kind of thing so I can check against ti make sure I am doing it correctly.

Thanks
Replied 22 Mar 2016 23:19:27
22 Mar 2016 23:19:27 Teodor Kuduschiev replied:
If you are following the steps above, then there won't be an issue.
If there is an issue, then most probably something is not properly set up - but until we see the page running, we can only try to guess what might be wrong.

Reply to this topic