Formula Question - Array, Case Contact Relationship

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    Formula Question - Array, Case Contact Relationship

    Hi all,

    I'm trying to get the contactId using formula, and it seem to be an array. This field is by default so I should be able to get the information but I'm failing.

    From fail experiment it seem to be an array data, but I can't get the actual ID of it. Anyone know how to get it?

    The entity I'm using is Cases, I have tried various formula of attribute. (contact.contactIds for example), and array\formula(), and directly getting the info just using the fieldname itself but I'm failing.

    Here some example of my failure:

    Code:
    contactsId
    contacts.Ids
    contact.contactsId
    contact.contactsIds
    array\at(contactsIds, contact.Ids)
    array\at(contact, contactsIds)
    array\at(contacts, contactsIds)
    array\unique(contacts)
    array\unique(contactsIds)
    array\unique(contactsId)
    array\length(contactIds)
    array\length(contactId)
    I either get nothing or just the word "array", or "0" hence the reason why I think I need to use Array formula

    And here a screenshot of the default field/entity:
    Click image for larger version  Name:	image.png Views:	0 Size:	19.6 KB ID:	91229
  • esforim
    Active Community Member
    • Jan 2020
    • 2204

    #2
    Off-topic: But would anyone know if Formula get run from top to bottom? So I would need to re-order the formula around the order I want it to be executed?

    Comment


    • Jakub Grufik
      Jakub Grufik commented
      Editing a comment
      yes I think the formula is being executed from top to bottom (I am 99% sure)

    • esforim
      esforim commented
      Editing a comment
      Thank you.
  • Vadym
    Super Moderator
    • Jun 2021
    • 346

    #3
    Hi esforim,

    Please try to use contactsIds attribute for array fetching or contactId for fetching the first array ID.

    Click image for larger version

Name:	contactsIds.png
Views:	441
Size:	32.9 KB
ID:	91264
    Click image for larger version

Name:	contactId.png
Views:	402
Size:	30.5 KB
ID:	91265
    Last edited by Vadym; 04-20-2023, 09:14 AM.

    Comment

    • esforim
      Active Community Member
      • Jan 2020
      • 2204

      #4
      Originally posted by Vadym
      Hi esforim,

      Please try to use contactsIds attribute for array fetching or contactId for fetching the first array ID.
      ​​​
      Hi Vadym, thank you for your help but the image doesn't seem to work. When I quote it I can see a "Temp" tag and a Base64 encode so it might be only visible on your computer.

      Not sure what the screenshot show, perhaps it have the correct formula?

      Comment

      • Vadym
        Super Moderator
        • Jun 2021
        • 346

        #5
        esforim Updated.

        Comment

        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #6
          Originally posted by Vadym
          esforim Updated.
          Thank you Vadym, I can see it now.

          Can you tell me how to split those array?

          I want to do something like this but not sure how to separate each of them:

          So it become something like this

          Contact ID: "2905151"
          Contact ID: "940909fa"

          Comment


          • lazovic
            lazovic commented
            Editing a comment
            Try use this formula scipt (first test it in Formula Sandbox):

            while(
            $i < array\length(contactsIds),
            (
            output\printLine(string\concatenate('Contact ID: ', array\at(contactsIds, $i)));
            $i = $i + 1;
            )
            );
        Working...