Page 1 of 1

Clear Signature with Automate Actions?

Posted: 24 Apr 2024, 00:39
by empmdk
I have a signature field and a date field for when the signature is added. I have the signature field set to trigger an automate action to set the date of when it was signed. The action for this is set to Enter Manually (no) and Value (0) to add the current date.
I'm trying to add an automate action button that will clear both the date and signature. This is what I have so far, set to a "execute php script".

Code: Select all

$entity_id = 96; //get entity ID
$item_id = [id]; //get current item ID

//prepare data to update
$data = [
  'field_1606' => '', //Clear signature
  'field_1613' => ' ' //Clear signature date
];

//run item update by id
items::update_by_id($entity_id,$item_id,$data);
This will remove both of them and in the database, the date field is set to "0". However, if I add the signature again, the date field does not get filled with the date and remains as "0". What am I missing or doing wrong here?

Also, for the signature image, where are these stored and how do I remove them?

Re: Clear Signature with Automate Actions?

Posted: 24 Apr 2024, 19:14
by support
When you add signature the extra record added to app_approved_items table.
To clear signature you have to remove record from app_approved_items related to current item.

Re: Clear Signature with Automate Actions?

Posted: 25 Apr 2024, 07:21
by empmdk
Testing with this and it seems to be working well. Is this good or any improvements you would recommend? Thank you.

Code: Select all

$entities_id = 96;
$item_id = [id];
$delete_signature = db_query("DELETE FROM app_approved_items WHERE entities_id = '" . ($entities_id) . "' AND items_id = '" . ($item_id) . "'");

Re: Clear Signature with Automate Actions?

Posted: 25 Apr 2024, 08:22
by support
sql query is correct.