Announcement

Collapse
No announcement yet.

ifThen with Record Count to update a Field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ifThen with Record Count to update a Field

    Hi Guys

    I created this formula yesterday and it worked perfect - this morning it is changing the status on every record instead of every record except the 1st
    • 2nd and subsequent records when saved, Status changes (or changes back) to “Duplicate”
    • 2nd and subsequent records that are Edited also changes back to “Duplicate”​

    Goal: using formula (using Espo Cloud) change the status to "Duplicate" when a duplicate record is created
    Path: I gathered from the forum the best way would be to create a field to ID the record (I'm using date/time/name) then count when that ID was 2 or more
    Ask: for a popup but it's Espo cloud, I thought maybe the "Notification" option in Workflow might work but since the record needs to be saved to determine a duplicate maybe this is fine, I couldn't get it to work anyway and say some mention regarding the Save process not intended for that

    attendIndex = string\concatenate(attendanceDate, ' + ', name, ' + ', contact.firstName , ' + ', contact.lastName);
    ifThen(
    record\count('Attendance', 'attendIndex>', 1), attendanceStatus='Duplicate'
    );​

    This is what I tested and worked yesterday

    • 2nd and subsequent records when saved, Status changes (or changes back) to “Duplicate”
    • 2nd and subsequent records that are Edited also changes back to “Duplicate”​
    Original record Status remains as selected or blank

    Do you know what I am doing wrong that it stopped working, maybe zero out fields? Is there a better way?

  • #2
    Hi crmclients,

    Please try this formula:

    Code:
    attendIndex = string\concatenate(attendanceDate, ' + ', name, ' + ', contact.firstName , ' + ', contact.lastName);
    ifThen(
    record\exists('Attendance', 'attendIndex=', attendIndex), attendanceStatus='Duplicate'
    );​

    Comment


    • #3
      thanks so much lazovic​ ! worked perfectly

      i did see that as one of many examples in the forum but couldn't work it out in my head the "=" vs ">"

      i see now, in case it helps anyone else
      • when a record is saved
      • check that this condition for the record exists(' look at the Attendance module', 'look for the value of the AttendIndex field and what it equals', 'compare it to itself AttendIndex'), change the attendaneStatus to 'Duplicate' if it equals itself)

      Comment

      Working...
      X