Skip Navigation

[Resolved] Notification trigger when custom fields modified triggers when fields are NOT

This thread is resolved. Here is a description of the problem and solution.

Problem:

I have a CPT, dogs, which users can edit via a post form. I have added a notification email which should send an email when one of two fields, Deceased (Checkbox) or Date of Death (Date) is modified. I thought it was working, but it seems that it also is sending the email if another field, Pre-titles, is changed. Maybe be for other fields as well, though Pre-titles is the only one I know for sure.

Solution:

You can setup the custom checkbox field, using options:

Value to store: 1

Save option: don't save anything to the database

See screenshot :

https://cdn.toolset.com/wp-content/uploads/2018/11/1152975-field_conditions.JPG

See details here:

https://toolset.com/forums/topic/notification-trigger-when-custom-fields-modified-triggers-when-fields-are-not/#post-1152975

Relevant Documentation:

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 7 replies, has 2 voices.

Last updated by helenmaryC 5 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1152666
triggers.PNG

I have a CPT, dogs, which users can edit via a post form. I have added a notification email which should send an email when one of two fields, Deceased (Boolean) or Date of Death (Date) is modified. I thought it was working, but it seems that it also is sending the email if another field, Pre-titles, is changed. Maybe be for other fields as well, though Pre-titles is the only one I know for sure.

I am attaching a screenshot of the Notification e-mail trigger section of the form so you can see how I have it set up. I couldn't find anything very specific in the documentation about this section, so I am guessing that i am just missing some simple point.

Thanks for your help.

#1152975
field-conditions.JPG
Deceased.JPG

Hi,

I assume we area talking about a Toolset form for editing post.

How do you setup the custom field "Deceased (Boolean)"?

I have tried these steps in my localhost in a fresh wordpress installation + Latest version of Toolset plugins, it works fine
1) Create two custom fields
- Checkbox field "Deceased", using options:
Value to store: 1
Save option: don't save anything to the database
See screenshot Deceased.JPG

- Date field "Date of Death"

2) Create a Toolset post form for editing the post.
Add an email notification with settings:
"Deceased" = 1
And
"Date of Death" <>
See screenshot field-conditions.JPG

It works fine, I can get the email notification, after setup any one of above two custom fields.

#1153171

I had a feeling it was something like this.

The actual problem I was having was that the notification was being triggered even if the conditions were NOT met. Turns out that the Save option, Don't save anything was what was causing the problem; I had it set to save "0" which made sense to me coming from an asp.net background.

My issue is resolved now. Thank you!

#1153212

I am reopening this because the fix caused a different issue.

I have a view that sets a filter based on the deceased field. I was previously checking for "The field Deceased is a boolean that is equal to the following Constant 0." That should longer work because 0 is no longer being saved, so I changed it to

"The field Deceased is a boolean that is different from the following Constant 1." This doesn't return any values. I also tried TRUE rather than 1, but that actually returned all of the records that DO have 1 saved which was really odd.

There was another support thread that suggested using number instead of boolean, but that required saving 0, which I can't do in order to get the notification trigger to work.

What am I missing?

#1153232

One other thing, it appears that dogs which have NOT been edited since making the change to "save options don't save anything" still show up in the view. It is only dogs which HAVE been edited that are excluded.

#1153358

I am going to leave this open for the moment, but I wanted to let you know that I may have it fixed. I am waiting for one more test to come back to prove that it is working under all circumstances.

I will let you know!

Thanks.

#1153519

There is a known issue in custom checkbox field:
https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

There is an issue with the Checkbox fields that save “0” when they are not set on a post.

The problem is that the Views plugin will still read them as “checked” when you perform a Search by those fields.

Currently, I suggest you use option "don't save anything to the database"

#1154077

This really surprises me since my view was working perfectly <b>until</b> I changed the setting to "don't save anything to the database." Switching back to saving 0 was what fixed my view issues. And my notification seems to be working, too, using "=1"

I'm going to go ahead and mark this as resolved, though we will see if it stays that way!

Thanks for your help.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.