Jump to content
  • 0
Sign in to follow this  
NiceDuck

Record authentication field upon delete

Question

Hello,

I tried to make a history log , the workflow is I have a main table, then if a user inserted, updated or deleted a record upon it, it will copy the values to a back up table along with the user id of the one who made the action.

I've been smooth sailing until I there was a sudden iceberg.

I have a trigger that activates upon insert, update and delete which is what i used to transfer the records to the back up table. The problem is, when I delete something, the trigger was unable to detect the user id of the user who made the action. It just directly transfer the record to the backup table. therefore, the user id of the transferred record is the user id of the last user who updated the record. not the one who deleted the record.

any ideas?

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 2

Hi @NiceDuck,

It will not be possible to capture who has deleted the record with Triggered action.

I would recommend using another Datapage with auto-submit JS which would insert a record to the history log table.

You configure your page to re-direct after record delete to the submission form  and also pass parameters on exit to the submission form.

However, this workflow would work only if you delete records from Details page.

Hope this helps.

Regards,

vitalikssssss

 

Share this post


Link to post
Share on other sites
  • 1

Hi NiceDuck,

I just want to ask, are you sure that it is the trigger is the one that is detecting which user made the actions? I think it was the data-page which is able to detect the current user via user authentication. In regards to the delete function.  It will just remove the selected record so it even though you have a field which captures the user id of the user, it wont update your records.

 I think on Delete triggers will only capture the deleted records,

 

Share this post


Link to post
Share on other sites
  • 1

Hello,

Thank you for the response Shiro and Vitaliksssss.

I just want to share what I did to resolve this issue.  Instead of using the Caspio's default delete functions, what I did is I added a erase field which is a yes/no filed on my records and I created a trigger that will delete those records with 'yes' values on these fields.

since the record is updated instead of deleted, the datapage will be able to capture the authentication fields first before the trigger delete the record. I will simplify my workflow as this

check the yes/no field assign for deletion --> update the record --> record is updated/inserted on the table --> trigger will check for records with a 'yes' value on its erase field --> delete those records.

This works on inline edit, bulk edit and details pages. However, if you deleted a record from Caspio Bridge, it will not be recorded on your history log. 

Hope this helps anyone.

quack.

Share this post


Link to post
Share on other sites
  • 0

Hello as a follow up to my last comment, I would like to share this with you guys. This is the trigger that I used. You may need to configure that to suit your needs but I hope this helps.

Aside from the features that are previously mentioned, this trigger is also capable of stating what kind of action is performed by the submitter and the time the action was submitted.

The table's I used in this trigger is named 'test_table4' and 'test_table5'. test_table 4 is the main table and the test table 5 as the history table. They are similar to each other with the only difference is 'test_table4' has a yes/no field named 'erase'. 

Hope it helps anyone.

Quack

P.S. The trigger is on the main table.

 

 

trigge_for_history_log.png

Share this post


Link to post
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...
Sign in to follow this  

×
×
  • Create New...