Adding a team to a document from a related Opportunity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LuckyLouie
    Senior Member
    • Nov 2017
    • 173

    Adding a team to a document from a related Opportunity

    Hello,

    Is it possible to use a formula to perform the following action:
    If a document is created and linked to a Opportunity, assign the teams from the Opportunity to the document.

    Thank you in advance for all your help.
  • macistda
    Member
    • Jul 2022
    • 88

    #2
    Yes that is possible. Two examples for documents:


    Code:
    // Firma finden wenn Auftrag und zuordnen
    
    $hatvorgang=ifThen(array\at(casesIds, 0), '1');
    if ($hatvorgang == '1' ) {
    $vorgang=array\at(casesIds, 0);
    $firmafind=record\attribute('Case', $vorgang, 'accountId');
    $firmavorhanden=array\includes(accounts1Ids, $firmafind);
    
    if ($firmavorhanden!=true && folderName=='Arbeitsberichte' ) {
    accounts1Ids=array\push(accounts1Ids, $firmafind);
    $firmafindname=record\attribute('Case', $vorgang, 'accountName');
    accounts1Names=object\set(accounts1Names, $firmafind, $firmafindname);
    }
    }
    Code:
    // Teams zuordnen aus Firmen
    
    // bisherige Zuordnung auslesen
    $allTeamIds = teamsIds;
    $allTeamNames = teamsNames;
    
    // Zugeordnete Firmen auslesen
    $k = 0;
    while($k < array\length(accounts1Ids)) {
    $teamIds = record\attribute('Account', array\at(accounts1Ids, $k), 'teamsIds');
    
    // Teams zuordnen zu Firma (Sub)-Schleife
    $j = 0;
    while ($j < array\length($teamIds)) {
    $teamId = array\at($teamIds, $j);
    $allTeamIds = array\push($allTeamIds, $teamId);
    $teamName = record\attribute('Team', $teamId, 'name');
    object\set($allTeamNames, $teamId, $teamName);
    $j = $j + 1;
    }
    
    $k = $k + 1;
    }
    
    // Team Ids und Teamnamen in jeweiliges Array schreiben
    $allTeamIds = array\unique($allTeamIds);
    teamsIds = $allTeamIds;
    teamsNames = $allTeamNames;

    Comment

    • macistda
      Member
      • Jul 2022
      • 88

      #3
      That example is designed for the flow:

      1st Step: get accounts for assigned cases (casesIds) from the document.
      2nd Step: get all Teams from account assigned to the case/document from step 1

      If you have opportunity you'll have to change the relations/variables of course.

      Comment

      • dreginald
        Senior Member
        • Sep 2018
        • 124

        #4
        Add formula in Document
        entity\addLinkMultipleId('teams', opportunity.teams);

        Comment

        Working...