Jump to content
  • 0

Trigger function with loop



I have a contact_address (CA) table that collects addresses for a contact. I would like to upload those addresses to a text field in the contact  table for convenience. 
The table trigger when a user inserts or updates a record in CA table is supposed to loop through the  addresses  and put those into a field in the contact table. 

In the loop shown, if a contact has 2 records in the CA table, the result is two copies of the same address, the inserted record. How do I get it to iterate through the CA records rather than repeating the same address twice? Thanks so much.

Screen Shot 2024-03-18 at 11.38.35 AM.png

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thank you so much! Volomeister!
Now my issue is that the trigger executes before the data is saved. So the concantenation uses the un-updated contact_address record. This must be a common issue. What are best practices to solve this?

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.

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.

  • Create New...