BPM - Check for the existence of a related entry.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alexisc
    Senior Member
    • Aug 2019
    • 135

    BPM - Check for the existence of a related entry.

    I need to create a new record when creating or updating an existing record:

    1. Created a new record with the status "in progress" -> create a related entry with the specified fields
    2. Updated status "in progress" of an existing record -> create a related entry with the specified fields
    3. Updated a record for which a linked record has already been created -> update some fields of a related entry

    To implement point 3, I need to check for the existence of a related entry. How do I check for the existence of a related entry?
  • Katia
    Junior Member
    • Jul 2021
    • 20

    #2
    Hi!

    1. You can try to use this Formula (as an example, it helps you to identify if the Lead with such an email exists):
    Code:
    record\exists('Lead', 'emailAddress=', from);
    More details in the documentation: https://docs.espocrm.com/administrat.../#recordexists.

    2. Or if you need to find out if the record exists with some specified criteria, then you can use this formula:
    Code:
    record\findOne(
    'Lead', 'createdAt', 'desc', 'emailAddress=', emailAddress);
    More information you can find here: https://docs.espocrm.com/administrat...#recordfindone.
    Last edited by Katia; 10-27-2021, 10:07 AM.

    Comment

    • alexisc
      Senior Member
      • Aug 2019
      • 135

      #3
      in the created related entry there is no email, name or phone,
      only the amount, date

      Comment

      • Katia
        Junior Member
        • Jul 2021
        • 20

        #4
        I wrote those Formulas as the example when you want to find out if the record with such an email exists. You just have to change the names of the fields and entities as you need.
        For example, if you want to find out if the record with such an amount or date exists, just use instead of 'emailAddress' field 'amount' or 'date'.

        Comment

        • alexisc
          Senior Member
          • Aug 2019
          • 135

          #5
          Originally posted by Katia
          I wrote those Formulas as the example when you want to find out if the record with such an email exists. You just have to change the names of the fields and entities as you need.
          For example, if you want to find out if the record with such an amount or date exists, just use instead of 'emailAddress' field 'amount' or 'date'.
          thanks for your help, the problem is that there may be coincidences in the amount and date

          I need to check for the existence of a related entry. I need to update a previously created entry if it already exists. If not, create a new one.

          Comment

          Working...