Dynamic Logic need help with formula

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crmclients
    Senior Member
    • Jul 2020
    • 295

    #1

    Dynamic Logic need help with formula

    I am trying to prevent saving the Lead if the Age is less than 62

    I was using the Dynamic Logic on the Age field that is calculating the date
    • cAge = datetime\diff(datetime\now(), cDOBYounger, 'years');
    but it doesn't seem to be working or I am missing something on how to use it?

    i didn't see a way on the Date field to validate a date for 62 years backwards from today,

    ideas? use a different approach?

    Attached Files
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1819

    #2
    you need, based on the age field value an API beforeSave formula: https://docs.espocrm.com/administrat...e-save-script/
    This would throw a message and make it impossible to save the record.

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1366

      #3
      you can try something as below using API BeforeSave


      PHP Code:
      if (
          
      entity\isAttributeChanged('cAge') &&
          
      cAge 62
      ) {
          
      recordService\throwForbidden("Age should be less than 62.");

      Rabii
      EspoCRM & Web Dev

      🔗 See what I’ve built for EspoCRM

      Comment

      Working...