Announcement

Collapse
No announcement yet.

Help with removing a link

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

  • Help with removing a link

    Hi, my "Contact" records have the default link to "Target Lists".

    This means in script I can say:
    Code:
    targetListsIds = array\push(targetListsIds, $appScanTargetId)
    And that will add the current Contact record to the target list with the ID $appScanTargetId.

    All great.

    How do I remove the Contact from that target list? I can check that it is there with the
    Code:
    array\includes(targetListsIds,$appScanTargetId)
    function, but I cannot see a way to get rid of it.

    Help apprecaited.

  • #2
    Ok, after much messing around I managed to do this. We really need an easier way. This is what I came up with:

    Code:
    ifThenElse(
       array\includes(targetListsIds,$appScanTargetId)
    ,
       (
          $i = 0;
          $target=list();
          while(
             $i < array\length(targetListsIds)
          ,
             (
                $currentId = array\at(targetListsIds, $i);
                ifThen(
                   $currentId != $appScanTargetId
                ,
                   $target = array\push($target,$currentId)
                );
                $i = $i + 1;
             )
          );
          // we now have the new list, put it in the final resting place
          targetListsIds = $target;
       )
    ,
       // The item was not there, so no need to remove it
    );

    Comment


    • shalmaxb
      shalmaxb commented
      Editing a comment
      wow, great solution!

  • #3
    you could user removeLinkMultipleID as below:

    Code:
    entity\removeLinkMultipleId(targetListsIds, $appScanTargetId);
    That should remove the contact from a the specific Id of target list provided.
    Rabii
    Web Dev

    Comment


    • #4
      Originally posted by rabii View Post
      you could user removeLinkMultipleID as below:

      Code:
      entity\removeLinkMultipleId(targetListsIds, $appScanTargetId);
      That should remove the contact from a the specific Id of target list provided.
      Thanks for the help, but that didn't work. However I changed it to:
      Code:
      entity\removeLinkMultipleId("targetLists", $appScanTargetId);
      And that seemed to do the trick; so thanks for the pointer.

      I had originally tried to use the
      Code:
      record\unrelate(ENTITY_TYPE, ID, LINK, FOREIGN_ID)
      function but could not get that one to work.

      It is not clear to me when you should use one or other function.

      Thanks for the help.

      Comment


      • rabii
        rabii commented
        Editing a comment
        it just takes time to get familiar with built in function. i am happy this helped, we are grateful for the developer team for such powerful software.
    Working...
    X