Process Definition - How to check for an empty datetime field

I want my Process Definition to check if, when creating a new record or editing an existing record, a user has filled in a datetime field. If they have, the Process will leave the entered date. If they have not, the Process will put in a calculated date based on the Created On datetime.

How can I check whether the field is empty? Is it simply <field> before '2000-01-01 12:00 AM'? Is there a better way?

  • It is better to accomplish that through sugarLogic formula on Studio:

    ifElse(

       equal($date_field, ""),

       // calculate it,

       $date_field

    )

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • That works to calculate the field, but if it's a calculated field then the user can't enter a value.

  • Hi Steve Jaspar,

    You can do that through code customization in vardefs.

    If you are familiar with the sugar development, you can set the field "enforced" property to false and it would become editable for the end-users.

    For eg:

    Navigate to field vardefs file, create it if doesn't exist.

    <root_directory>/custom/Extension/modules/<module_name>/Ext/Vardefs/sugarfield_<field_name>.php

    //set enforced to false

    $dictionary['<module_class_name']['fields']['<field_name']['enforced'] = false; //where <module_class_name> is generally singular for standard modules i.e. "Account" for "Accounts" but for custom module, it is the same as module name.

    Perform Quick Repair & Rebuild from the Admin -> Repair section.

    Let us know if this helps.

    Regards

  • Thanks for the info, but we're a new Sugar installation and don't yet have any developers up to speed. That's why I was working on this requirement in the Process Definition.

  • What about adding a checkbox and use the formula from Andres Lopez to tick the checkbox in case of the date_time field is empty.

    Now use this checkbox in process auth... err now its called "SugarBMP" to set the calculated date in case of the checkbox is ticked.

    (Depending on the scenario you have you may also untick the checkbox afterwards with the same process to avoid the date will be set again on the next record save event)

    Cheers

    Björn Canales Pfisterer

    Technical Support Manager

    provalida GmbH

  • That did it! Thanks so much!

    I'm actually ticking the checkbox if the date field is populated, then the Process only calculates if the checkbox is false - so no need to modify the checkbox in the Process.

  • Yeah! Go ahead and mark the thread as solved :-)

    Have a nice evening!