Clear Signature with Automate Actions?

Ask your questions here.
Post Reply
empmdk
Posts: 169
Joined: 21 Nov 2016, 05:56
Name: Brandon Ramey

Clear Signature with Automate Actions?

Post 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?
User avatar
support
Site Admin
Posts: 6206
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Clear Signature with Automate Actions?

Post 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.
empmdk
Posts: 169
Joined: 21 Nov 2016, 05:56
Name: Brandon Ramey

Re: Clear Signature with Automate Actions?

Post 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) . "'");
User avatar
support
Site Admin
Posts: 6206
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Clear Signature with Automate Actions?

Post by support »

sql query is correct.
Post Reply