Announcement

Collapse
No announcement yet.

Workflow to create linked records - one for very person in a taskList

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

  • Workflow to create linked records - one for very person in a taskList

    Hello,

    I've an entity TaskList with for example 4 liked persons
    I've an entity Firmen with 1:n to personen
    I've an entity Kontakte (a list of all mails, eMails, calls, meetings, visits etc.) with n:1 to TaskList, n:1 to Firmen, n:1 to Personen
    I've created a workflow with manual trigger (Button) for target entity TaskList
    In this workflow I create an action with following formula:
    ------------schnipp-------------
    /* für every person in TagetList */
    $source = personensIds;
    $target = list();
    $fi = '';
    $ka = 'in Verteiler';
    $ma = 'xyz GmbH';
    $be = string\concatenate('Verteiler: ', name);
    $an = 'Verteiler Aussendung';
    $mid = mitarbeiterId;
    $uid = assignedUserId;
    $vid = id;
    $i = 0;
    while(
    $i < array\length($source),
    (
    $target = array\at($source, $i);
    $fi = record\attribute('Personen', $target, 'firmenId');
    record\create('Kontakte', 'firmenId', '$fi', 'personenId', '$target', 'kontaktdatum', datetime\today(), 'kontaktart', '$ka', 'mandant', '$ma', 'betreff', '$be', 'anlass', '$an', 'mitarbeiterId', '$mid', 'assignedUserId', '$uid', 'taskListId', '$vid');
    );
    $i = $i + 1;
    );​
    ---------------schnapp--------------
    BUT - there is created only ONE, EMPTY record.

    What's my fault?

    Christoph

  • #2
    Hi ctheuring,

    Could you provide the error log of your instance for a more detailed analysis?

    In any case, even without an error log, I can already tell that there are several errors in the part of the line where the record\create() function is located.
    If you want to fill fields with values from previously defined variables, you do not need to put them in upper brackets. That is, the line should look like this:
    Code:
    record\create('Kontakte', 'firmenId', $fi, 'personenId', $target, 'kontaktdatum', datetime\today(), 'kontaktart', $ka, 'mandant', $ma, 'betreff', $be, 'anlass', $an, 'mitarbeiterId', $mid, 'assignedUserId', $uid, 'taskListId', $vid);
    Also please make sure that the Kontakte entity has exactly this name, and not the name Contact (in English):

    Click image for larger version

Name:	image.png
Views:	98
Size:	22.7 KB
ID:	102778

    Comment


    • #3
      Hello lazovic,

      thanks for your time to help me.
      1. there is no log with errors about this workflow
      2. I've made a 2nd workflow to test it without "while" - only create ONE record and without brackets around variables:
      Click image for larger version  Name:	grafik.png Views:	0 Size:	53.1 KB ID:	102859
      Result: created the record, but ALL the temp-variable-fields (with$) are not set (bettter: set with null):
      but: in sandbox (see screenshot attached) they are without $anz and $opt -> ok​

      Where is the mistake?

      Christoph
      Attached Files
      Last edited by ctheuring; 02-18-2024, 10:06 AM.

      Comment


      • #4
        This code in a Workflow runs:
        $be = string\concatenate('Verteiler: ', targetList.name);
        $bes = targetList.description;
        $mid = targetList.mitarbeiterId;
        $uid = targetList.assignedUserId;
        $vid = targetListId;
        $tea = record\findRelatedMany('TargetList', $vid, 'teams', 5);
        $anz = record\count('TargetListPersonen', 'targetListId', $vid);
        $out = record\count('TargetListPersonen', 'targetListId', $vid, 'optedOut', 1);
        $anm = string\concatenate($bes, ' mit ', $anz - $out, ' Personen');
        record\create('Kontakte', 'targetListId', $vid, 'firmenId', '6380a6c5824f8bbd7', 'kontaktart', 'in Verteiler', 'anlass', 'Verteiler Aussendung', 'kontaktdatum', datetime\today() , 'mandant', 'Hommel GmbH', 'mitarbeiterId', $mid, 'betreff', $be, 'anmerkung', $anm, 'assignedUserId', $uid, 'teams', $tea);​
        ... but still 3 problems remain:
        1. I've found no solution to "transfer" (all) teams from entity TargetList to entity Kontakte
        2. it's not possible to use the sandbox to test the code
        and - the main problem - 3. this code create TWO records in the entity Kontakte: one with ALL fileds empty and 2nd the expeted record filled all fields. I think, the 2nd results from the above code "record\create(...".
        Remain the question: How to suppress the (empty) record?
        Hint: is it caused by an intern code in conjunction with the n:n relationship from TaksList to the entity contatcs? The entity contacts is not used in my system ... but I can't remove it ...

        Christoph
        Last edited by ctheuring; 02-18-2024, 10:50 AM.

        Comment

        Working...
        X