Jump to content
  • 0

Table trigger to simultaneously count new value and table values


Altair

Question

6 answers to this question

Recommended Posts

  • 0

What you can do is use this task trigger config as a template if you want to combine the old table data plus the newly inserted data.
image.thumb.png.6277a6ae47343629e0c3423785b0d67b.png

With this, you can different sorts of operations and to manipulate values (pre-insert values and post-insert value) using a trigger upon insert.

Link to comment
Share on other sites

  • 0

First question is, how are you counting the records. Do you have a parent table where the counter is going to be saved?

The reason why the inserted record is not being counted, because if you do the Select count on the trigger - the trigger will be counting the records that are currently inside the table. 

So when it comes to counting or summing the values, you need to include the #inserted value. Or in this case, you can just simply add 1 to the Select Count query. 

 

Hope this helps. 

 

Glitch();

Link to comment
Share on other sites

  • 0

I took a slightly different approach, by counting the existing distinct records in the target table and adding 1 if the distinct record value does not already exist, and combining it with a very simple triggered action, like this as in my test app:

In the form, I added the 'Count' field:

(SELECT COUNT (DISTINCT Perspective) FROM CasePerspectives WHERE CaseID=target.[@field:CaseID])  + [@cbParamVirtual1]

And a virtual field Virtual 1:

CASE WHEN (SELECT COUNT (DISTINCT Perspective) FROM CasePerspectives WHERE CaseID=target.[@field:CaseID] AND Perspective = target.[@field:Perspective]) = 0 THEN 1 ELSE 0  END

The 'Count' value will then be the number of distinct values in the last saved record.

The  following triggered action in the target table:

image.png.249f9c4d971156fd387ab82f4989581f.png

 

Link to comment
Share on other sites

  • 0
22 hours ago, Flowers4Algernon said:

Hello! Just wanted to share this how-to link should you guys want to read more about Triggered Actions: https://howto.caspio.com/tables-and-views/triggered-actions/

Thanks, I have read it a few times, but might need it once more. I would like a more comprehensive description of triggered actions, also the more complex! Right now I need a triggered action that recounts a number when a distinct value of another field is removed..

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...