I'm trying to build a formula that says if start date field is <= today & end date field is >= today or start date field is <=today & end date field is black then active checkbox = true
I'm trying to build a formula that says if start date field is <= today & end date field is >= today or start date field is <=today & end date field is black then active checkbox = true
The sugarLogic formula may looks like that:
or(and(isBefore($date_start, now()), isBefore($date_end, now())), and(isBefore($date_start, now()), equal($date_end, "")))
Regards
Hi Braedon Owen,
I was able to achieve this functionality with the following formula on a calculated checkbox field:
or(and(not(isAfter($start_date_c,now())),not(isBefore($end_date_c,today()))),and(not(isAfter($start_date_c,now())),not(greaterThan(strlen(toString($end_date_c)),0))))
Here are a few notes regarding the formula and behavior:
I hope this helps!
That works perfectly, thanks Chris!
I do have another question surrounding this; will the record automatically update itself to say inactive/active or would that be a process that is created?
for example, a promotion is created with start date tomorrow. When I save that, the checkbox for 'active' will be false, will it show active tomorrow automatically?
Hi Braedon,
Fields with Sugar Logic require a save event in order to update, so the checkbox would not automatically update in the scenario you present. The most likely method to achieve this behavior would be via SugarBPM. One consideration to make there is the volume of records that would need to be continually evaluated by SugarBPM, because it may cause a performance concern. The reason for the performance concern is the process definition would need to incorporate wait events and those can be expensive to process. If there is a high volume of records (along the line of 1000s, not 100s) to continually evaluate, a custom scheduler may be a better solution to address this use case. My company, Upsert, develops custom schedulers to meet these use cases.
With regards to SugarBPM, your use case has two distinct scenarios:
If you need further guidance on leveraging SugarBPM, it's probably best you start a separate thread in the community, and I will be happy to participate.
Hi Braedon,
In learning more about the defects with using isAfter() and today() together from Sugar Support, I was able to craft a better formula that improves the user experience. I updated the original post with that new formula and comments.