AEM Forms 中心のワークフローステップのためのユーザーまたはグループの動的な選択 dynamically-select-a-user-or-group-for-aem-forms-centric-workflow-steps

実行時に AEM Forms Workflow のユーザーまたはグループを選択する方法について説明します。

大規模な組織では、プロセスのユーザーを動的に選択する必要があります。 例えば、顧客に対するエージェントの近さに基づいて、顧客に提供するフィールドエージェントを選択します。 このシナリオでは、エージェントは動的に選択されます。

OSGi における Forms Workflow のタスクの割り当て手順および Adobe Sign 手順では、ユーザーを動的に選択するオプションが用意されています。ECMAScript バンドルまたは OSGi バンドルを使用して、タスクの割り当て手順の担当者を動的に選択したり、ドキュメントに署名手順の署名者を選択したりできます。

ECMAScript を使用したユーザーまたはグループの動的な選択 use-ecmascript-to-dynamically-select-a-user-or-group

ECMAScript はスクリプト言語です。 クライアントサイドのスクリプティングやサーバーアプリケーションに使用されます。 ECMAScript を使用してユーザーまたはグループを動的に選択するには、次の手順を実行します。

  1. CRXDE Lite を開きます。URL は https://'[server]:[port]'/crx/de/index.jsp です

  2. 以下のパスに、拡張子が .ecma のファイルを作成します。パス(ノード構造)が存在しない場合は作成します。

    • (タスクの割り当て手順のパス)/apps/fd/dashboard/scripts/participantChooser
    • (署名手順のパス)/apps/fd/workflow/scripts/adobesign
  3. ユーザーを動的に選択するロジックを持つ ECMAScriptを.ecma ファイルに追加します。 「すべて保存」をクリックします。

    サンプルスクリプトについて詳しくは、「ユーザーまたはグループを動的に選択するためのサンプル ECMAScripts」を参照してください。

  4. スクリプトの表示名を追加します。 この名前は、ワークフローステップに表示されます。 名前を指定するには、以下の手順を実行します。

    1. スクリプトノードを拡張します。jcr:content ノードを右クリックしてから、「Mixins」をクリックします。

    2. Mixin を編集ダイアログに mix:title プロパティを追加して、「OK」をクリックします。

    3. スクリプトの jcr:content ノードに以下のプロパティを追加します。

      table 0-row-3 1-row-3
      名前 タイプ
      jcr:title 文字列 スクリプトの名前を指定します。 例えば、最も近いフィールドエージェントを選択します。 この名前は、タスクの割り当て手順とドキュメントに署名手順で表示されます。
    4. すべて保存」をクリックします。スクリプトがAEM Workflow のコンポーネントで選択可能になります。

      script

ユーザーまたはグループを動的に選択するためのサンプル ECMAScript sample-ecmascripts-to-dynamically-choose-a-user-or-a-group

以下のサンプル ECMAScript では、タスクの割り当て手順に担当者を動的に選択します。このスクリプトでは、ユーザーはペイロードのパスに基づいて選択されます。 このスクリプトを使用する前に、スクリプトで言及されているすべてのユーザーがAEMに存在することを確認します。 スクリプトで指定されたユーザーがAEMに存在しない場合、関連するプロセスが失敗する可能性があります。

function getParticipant() {

var workflowData = graniteWorkItem.getWorkflowData();

if (workflowData.getPayloadType() == "JCR_PATH") {

var path = workflowData.getPayload().toString();
     if (path.indexOf("/content/geometrixx/en") == 0) {
    return "user1";
    }
   else {
              return "user2";
            }
}
}

以下のサンプル ECMAScript は、Adobe Signの手順の担当者を動的に選択します。 次のスクリプトを使用する前に、スクリプトで指定されているユーザー情報(電子メールアドレスと電話番号)が正しいことを確認してください。 スクリプトで説明されているユーザー情報が正しくない場合、関連するプロセスが失敗する可能性があります。

NOTE
Adobe Sign用の ECMAScript を使用する場合、スクリプトは/apps/fd/workflow/scripts/adobesign/の crx-repository に存在し、ユーザーのリストを返すために getAdobeSignRecipients という名前の関数を持っている必要があります。
function getAdobeSignRecipients() {

    var recipientSetInfos = new Packages.java.util.ArrayList();

    var recipientInfoSet = new com.adobe.aem.adobesign.recipient.RecipientSetInfo();
    var recipientInfoList = new Packages.java.util.ArrayList();
    var recipientInfo = new com.adobe.aem.adobesign.recipient.RecipientInfo();

    var email;
    var recipientAuthenticationMethod = com.adobe.aem.adobesign.recipient.RecipientAuthenticationMethod.PHONE;
    //var recipientAuthenticationMethod = com.adobe.aem.adobesign.recipient.RecipientAuthenticationMethod.NONE;
    var securityOptions = null;

    var phoneNumber = "123456789";
    var countryCode = "+1";
    var recipientPhoneInfo = new Array();
    recipientPhoneInfo.push(new com.adobe.aem.adobesign.recipient.RecipientPhoneInfo(phoneNumber, countryCode));

     securityOptions = new com.adobe.aem.adobesign.recipient.RecipientSecurityOption(recipientAuthenticationMethod, recipientPhoneInfo , null);

    email = "example@example.com";

    recipientInfo.setEmail(email);
    recipientInfo.setSecurityOptions(securityOptions);

    recipientInfoList.add(recipientInfo);
    recipientInfoSet.setMemberInfos(recipientInfoList);
    recipientSetInfos.add(recipientInfoSet);

    return recipientSetInfos;

}

ユーザーまたはグループを動的に選択するための Java インターフェイスの使用 use-java-interface-to-dynamically-choose-a-user-or-group

以下を使用すると、 RecipientInfoSpecifier Adobe Signおよびタスクの割り当て手順でユーザーまたはグループを動的に選択する Java インターフェイス。 RecipientInfoSpecifier Java インターフェイスを使用する OSGi バンドルを作成して、AEM Forms サーバーにデプロイできます。これにより、AEM Workflow のタスクの割り当てコンポーネントとAdobe Signコンポーネントで、このオプションを選択できるようになります。

以下のコードサンプルをコンパイルするには、AEM Forms Client SDK jar および granite jar ファイルが必要です。これらの jar ファイルを外部の依存関係として OSGi バンドルプロジェクトに追加します。 任意の Java IDE を使用して、OSGi バンドルを作成できます。 次の手順は、Eclipse を使用して OSGi バンドルを作成する手順を示しています。

  1. Eclipse IDE を開きます。 ファイル新規プロジェクト ​に移動します。

  2. ウィザードを選択画面で、Maven プロジェクト ​を選択し、「次へ」をクリックします。

  3. 新しい Maven プロジェクトで、デフォルトをそのままにして、「 次へ. アーキタイプを選択して「次へ」をクリックします。例えば、maven-archetype-quickstart などです。 指定 グループ ID, アーティファクト ID, version、および パッケージ プロジェクトの場合は、をクリックします。 完了. プロジェクト構造が作成されます。

  4. 編集用に pom.xml ファイルを開き、ファイルのすべてのコンテンツを以下に置き換えます。

    code language-xml
    <project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>getAgent</groupId>
        <artifactId>assignToAgent</artifactId>
        <version>1.0</version>
        <packaging>bundle</packaging><!-- packaging type bundle is must -->
    
        <name>assignToAgent</name>
        <url>https://maven.apache.org</url>
        <repositories>
            <repository>
                <id>adobe</id>
                <name>Adobe Public Repository</name>
                <url>https://repo1.maven.org/maven2/com/adobe/</url>
                <layout>default</layout>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>adobe</id>
                <name>Adobe Public Repository</name>
                <url>https://repo1.maven.org/maven2/com/adobe/</url>
                <layout>default</layout>
            </pluginRepository>
        </pluginRepositories>
    
        <dependencies>
            <dependency>
                <groupId>com.adobe.aemfd</groupId>
                <artifactId>aemfd-client-sdk</artifactId>
                <version>6.0.138</version>
            </dependency>
            <dependency>
                <groupId>com.adobe.granite</groupId>
                <artifactId>com.adobe.granite.workflow.api</artifactId>
                <version>1.0.0</version>
            </dependency>
    
            <dependency>
                <groupId>org.osgi</groupId>
                <artifactId>org.osgi.core</artifactId>
                <version>4.2.0</version>
                <scope>provided</scope>
            </dependency>
    
            <dependency>
                <groupId>org.apache.felix</groupId>
                <artifactId>org.apache.felix.scr.annotations</artifactId>
                <version>1.7.0</version>
    
            </dependency>
    
            <dependency>
                <groupId>org.apache.sling</groupId>
                <artifactId>org.apache.sling.api</artifactId>
                <version>2.2.0</version>
    
            </dependency>
    
        </dependencies>
    
        <!-- ====================================================================== -->
        <!-- B U I L D D E F I N I T I O N -->
        <!-- ====================================================================== -->
        <build>
            <plugins>
    
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <extensions>true</extensions>
                    <configuration>
                        <instructions>
                            <Bundle-SymbolicName>com.aem.assigntoAgent-bundle</Bundle-SymbolicName>
                        </instructions>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-scr-plugin</artifactId>
                    <version>1.9.0</version>
                    <executions>
                        <execution>
                            <id>generate-scr-descriptor</id>
                            <goals>
                                <goal>scr</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
    </project>
    
  5. RecipientInfoSpecifier Java インターフェイスを使用するソースコードを追加して、タスクの割り当て手順にユーザーまたはグループを動的に選択できます。サンプルコードについては、 Java インターフェイスを使用したユーザーまたはグループの動的選択のサンプル.

  6. コマンドプロンプトを開き、OSGi バンドルプロジェクトを含むディレクトリに移動します。 以下のコマンドを使用して OSGi バンドルを作成します。

    mvn clean install

  7. バンドルをAEM Formsサーバーにアップロードします。 AEM パッケージマネージャーを使用して、バンドルを AEM Forms サーバーに読み込むことができます。

バンドルをインポートすると、Adobe Sign 手順やタスクの割り当て手順で、ユーザーまたはグループを動的に選択する Java インターフェイスを選択できるようになります。

ユーザーまたはグループを動的に選択するためのサンプル Java コード sample-java-code-to-dynamically-choose-a-user-or-a-group

以下のサンプル Java コードでは、Adobe Sign 手順に担当者を動的に選択します。OSGi バンドルでコードを使用します。 以下に示すコードを使用する前に、コードに記載されているユーザー情報(E メールアドレスと電話番号)が正しいことを確認してください。 コードで説明されているユーザー情報が正しくない場合、関連するプロセスが失敗する可能性があります。

/*************************************************************************

 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 * Copyright 2016 Adobe Systems Incorporated
 * All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.aem.impl;

import java.util.ArrayList;
import java.util.List;

import com.adobe.aem.adobesign.recipient.RecipientAuthenticationMethod;
import com.adobe.aem.adobesign.recipient.RecipientInfo;
import com.adobe.aem.adobesign.recipient.RecipientPhoneInfo;
import com.adobe.aem.adobesign.recipient.RecipientSecurityOption;
import com.adobe.aem.adobesign.recipient.RecipientSetInfo;
import com.adobe.fd.workflow.adobesign.api.RecipientInfoSpecifier;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;

/**
 * <code>DummyRecipientInfoSpecifier implementation. A sample code to write implementation of RecipientInfoSpecifier to choose recipients/code>...
 */
@Service

@Component(metatype = false)
public class DummyRecipientChoser implements RecipientInfoSpecifier {
    public List<RecipientSetInfo> getAdobeSignRecipients(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {

        List<RecipientSetInfo> recipientSetInfos = new ArrayList<RecipientSetInfo>();

                //First Recipient

                RecipientSetInfo recipientInfoSet1 = new RecipientSetInfo();
                List<RecipientInfo> recipientInfoList = new ArrayList<RecipientInfo>();
                RecipientInfo recipientInfo1 = new RecipientInfo();//Member to first recipient

                String email;

                RecipientAuthenticationMethod recipientAuthenticationMethod = RecipientAuthenticationMethod.WEB_IDENTITY;
                RecipientSecurityOption securityOptions = null;

                String phoneNumber = "123456789";
                String countryCode = "+1";
                RecipientPhoneInfo[] recipientPhoneInfo = new RecipientPhoneInfo[1];  //if multiple phone numbers, size>1
                recipientPhoneInfo[0] = new RecipientPhoneInfo(phoneNumber, countryCode);
                securityOptions = new RecipientSecurityOption(recipientAuthenticationMethod, recipientPhoneInfo , null);

                email = "example@example.com";

                recipientInfo1.setEmail(email);
                recipientInfo1.setSecurityOptions(securityOptions);

                recipientInfoList.add(recipientInfo1);  //Add member

                recipientInfoSet1.setMemberInfos(recipientInfoList);

                //Second Recipient

                RecipientSetInfo recipientInfoSet2 = new RecipientSetInfo();
                List<RecipientInfo> recipientInfoList2 = new ArrayList<RecipientInfo>();

                recipientAuthenticationMethod = RecipientAuthenticationMethod.PHONE;
                securityOptions = null;

                phoneNumber = "987654321";//"0123456789";

                countryCode = "+1";
                RecipientPhoneInfo[] recipientPhoneInfo_1 = new RecipientPhoneInfo[1];
                recipientPhoneInfo_1[0] = new RecipientPhoneInfo(phoneNumber, countryCode);
                securityOptions = new RecipientSecurityOption(recipientAuthenticationMethod, recipientPhoneInfo_1 , null);

                email = "example2@example.com";//"dummymail2@domain.com";

                RecipientInfo recipientInfo2  = new RecipientInfo();
                recipientInfo2.setEmail(email);
                recipientInfo2.setSecurityOptions(securityOptions);

                recipientInfoList2.add(recipientInfo2);  //Add member

                recipientInfoSet2.setMemberInfos(recipientInfoList2);

                //*********************************

                recipientSetInfos.add(recipientInfoSet1);
                recipientSetInfos.add(recipientInfoSet2);

        return recipientSetInfos;

    }

}
recommendation-more-help
19ffd973-7af2-44d0-84b5-d547b0dffee2