用于动态选择用户或组的示例ECMAScript
以下示例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步骤动态选择被分配人。 在使用以下脚本之前,请确保脚本中提到的用户信息(电子邮件地址和电话号码)正确无误。 如果脚本中提到的用户信息不正确,则相关进程可能会失败。
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界面动态选择用户或组
您可以使用RecipientInfoSpecifier Java界面动态选择Adobe Sign的用户或组并分配任务步骤。 您可以创建一个使用了RecipientInfoSpecifier Java接口的OSGi捆绑包,并将其部署到AEM Forms服务器。 这使该选项可以在AEM Workflow的分配任务和Adobe Sign组件中进行选择。
您需要AEM Forms客户端SDK jar和granite jar文件来编译下面列出的代码示例。 将这些jar文件作为外部依赖项添加到OSGi捆绑包项目中。 您可以使用任何Java IDE创建OSGi捆绑包。 以下过程提供了使用Eclipse创建OSGi捆绑包的步骤:
-
打开Eclipse IDE。 导航到 文件> 新建项目。
-
在选择向导屏幕上,选择 Maven项目,然后单击 下一步。
-
在新的Maven项目中,保留默认值,然后单击 下一步。 选择原型并单击 下一步。 例如,maven-archetype-quickstart。 为项目指定 组ID、项目ID、版本 和 包,然后单击 完成。 将创建项目。
-
打开pom.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>
-
添加使用RecipientInfoSpecifier Java接口为“分配”任务步骤动态选择用户或组的源代码。 有关示例代码,请参阅使用Java接口动态选择用户或组的示例。
-
打开命令提示符并导航到包含OSGi捆绑包项目的目录。 使用以下命令创建OSGi捆绑包:
mvn clean install
-
将捆绑包上传到AEM Forms服务器。 您可以使用AEM包管理器将包导入到AEM Forms服务器。
导入捆绑包后,在Adobe Sign和分配任务步骤中,提供了用于选择用于动态选择用户或组的Java界面的选项。