How to add contact to targetlist using formula?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Enju
    Senior Member
    • Apr 2018
    • 128

    How to add contact to targetlist using formula?

    Hello,
    How to add contact to targetlist using formula?
    I try use:
    HTML Code:
    record\relate('Contact', $id_contact, 'targetLists', '???')
    but, target list has not id
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    #2
    you should use the id of the foreign entity which is the target list as below:

    PHP Code:
    record\relate('Contact', $id_contact, 'targetLists', $tagertListId) 
    
    Rabii
    Web Dev

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #3
      Or if you are using formula e.g in your contact formula script you would do something as below:

      PHP Code:
      entity\addLinkMultipleId('targetLists', $tagertListId) 
      
      This will link both entities
      Rabii
      Web Dev

      Comment

      • Enju
        Senior Member
        • Apr 2018
        • 128

        #4
        thank you

        Comment

        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #5
          I notice you guy use
          $ without declaring anything
          For $tagertListId​=="someID"

          We don't need do this? Or it was omitted in this thread?

          Comment

          • rabii
            Active Community Member
            • Jun 2016
            • 1250

            #6
            i am just sharing an exmaple $targetListId would be a variable that store the id of the target list found e.g

            PHP Code:
            $targetListId = record\findOne('TargetList', 'createdAt', 'desc', 'name=', 'Main Target List');
            
            entity\addLinkMultipleId('targetLists', $tagertListId); 
            
            Rabii
            Web Dev

            Comment


            • esforim
              esforim commented
              Editing a comment
              That what I expecting, I was thinking there was some build in variable feature.
          Working...