function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marco Sozzi 5Marco Sozzi 5 

distinguish the source of a checkbox value

Hello,
is there a way to distinguish (in a trigger or other)  if a checkbox field has been populated by the user or by the system with a defult value? I have a checkbox with default value Unchecked (false). When the object is saved the field containd FALSE value and i have to distinguish if the user has inserted it or if the user has not inserted any value for the field (null) and the system has put the default value.

Thank you.
Marco.
Kelly KKelly K

Hi Marco,

I don't think there's a 100% surefire way of going about this with the present state of the data, but there are a few things that can be done if it's a serious issue.

1. When you have a checkbox and the default is false, then API inserts and in the browser this will be loaded as false - you can safely assume that the user did not touch it on creation.
2. You could add tracking if the field is sensitive enough and it's worth using one of the 20 you get. That will show you if the field was updated from true to false in the object history.
3. If you're out of fields for tracking, you can set up a separate field(s) and then turn on a workflow rule to run update of that checkbox to fill out the separate fields with who and when. (This can be preferred if you need it for reporting outside of the clunky history reports).


Unfortunately, with any of those methods, if you have a workflow rule or a trigger that sets it, it will always run in context of the user, so there's not a way to know if the user manually toggled it or if the trigger/workflow updated it.

However. If there's additional criteria to the trigger/workflow that the user would normally not trip, you could have it update a separate field outside of that, identifying that it was a system update.

Hope this helps.
Kelly

Marco Sozzi 5Marco Sozzi 5
Hi Kelly, thanks for your reply.
I also fear that ther is not a safe way, but i'm still hopeful.
1) if i have a checkbox and the default is false, if i recevice (for example) a web2lead with false value i cant distinguish if the value is false because of the default value or because of a value sent by W2L.
2) i tried add tracking for the field but in insert you can only see "created" row in history related object, without any other row specifying any modify
3) unfortunately on creation the function ISCHANGED (for example) doesn't work because the value is already set and is not considered as changed (even if different from the default value, as if there is not PRIORVALUE) so the workflow doesn't fire.

When fires triggers and workflows the default value is already set, so in these cases i can not know if user has passed it or not.

Is it possible to make a checkbox nillable (without default value)?

Thank you.
Marco.
Kelly KKelly K

Negative. Checkboxes can only be true or false.

Also, with ISCHANGED, you're right, that's only for updated records, but you can use ISNEW() as well. When I'm fishing for an update to a particular record, I could do 

OR(
ISNEW(),
ISCHANGED(field_name)) 

and that's specific enough.

All of that said though, what you might want to consider is converting your checkbox to a picklist with 3 potential selections: blank/null, true, false. If you set the default of the field to 'false' - this would only affect records created in the browser. Your web2lead process is an api connection, and unless it was specified to update the field, any records it creates would come over as 'blank/null.'