Jump to content
  • 0

Trigger To Insert Record Only Once Even with Multiple Updates


PlaceWorks

Question

I'm trying to create a trigger so that when the field CCTAproject_id in my parent table "tbl_projects" is updated, rows will be created in all of my related tables and given the same CCTAproject_id. I only want this to happen once (due to the way I set up the new submission form, it generates a random string and then the client will update this field once to assign it a new ID number). However, whenever I update any field in that same record in the parent table, it creates another record in the related tables. Ex, I update different fields for one record three different times and three blank cells with that same ID are generated. 

I thought of creating a workflow that If the CCTAproject_id doesn't exist, then add the new record.  When I tried dragging in the If/Then operator, it did not give me any fields or tables as options to select from. Is there another workaround to add the record only once to my related tables?

 

My update forms are split between many related tables, which are all linked through CCTAproject_id. When a new project is added, that records only gets added to the parent table, not the related tables, thus the need for this trigger.  

image.png

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @PlaceWorks

Have you tried the comparison type, "NOT IN"?

This will allow you to check if that ID is existing in the other table. 

As I understand, This trigger should insert a Data in the other tables upon update, which explains the behavior that it inserts a new data upon update. 

I have a similar workflow on my app, that ifever an ID is not existing, it will insert a new record. If it is existing, update the record. 

Tables_2019-May-01_2304.zip

Hope this helps. 

Link to comment
Share on other sites

  • 0

See below.

I trigger a record to be inserted into the renewedlog_invoice when a record is tagged as renewed in the insurancehouse_members_db table.

If the record is updated twice two entry are made in the Renewedlog_Invoice Table.

Rather than a second record being inserted into the Renewedlog_Invoice Table I would prefer it update the first record that was created when it first triggered.

I think similar Place works issue above your 

Have you tried the comparison type, "NOT IN"? 

May fix this for me???

Many Thanks for your help

trigger.png

Tableresults.png

Link to comment
Share on other sites

  • 0

@Scott

Hello!

Your trigger should consist of two part.
First one will insert the entry into the log table if the log table does not contain the ID of a particular entry.
The second will update the needed entry if it is already present within the log table.

Please find the app with the example attached :
FORUM_Trigger_Insert_Update_Based_on_Presence_1_0_2019-Jun-19_0714.zipjoxi_screenshot_1560928427069.png.9bb753e58da7fd287828020718328f18.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...