[集成]{class="badge positive"}

创建数据元素

[AEM Formsas a Cloud Service]{class="badge informative"}

在Tags属性中,我们添加了两个新数据元素(ApplicationsStateOfResidence和validationError)。

自适应表单

ApplicantStateOfResidence

通过在扩展下拉列表中选择​ Core ​并为数据元素类型选择​ 自定义代码,配置了​ ApplicantStateOfResidence ​数据元素,如下面的屏幕快照所示
申请人 — 国家 — 居住地

以下自定义代码用于捕获​ 状态 ​自适应表单字段中的值。

// use the GuideBridge API to access adaptive form elements
//The state field's SOM expression is used to access the state field
var ApplicantsStateOfResidence = guideBridge.resolveNode("guide[0].guide1[0].guideRootPanel[0].state[0]").value;
_satellite.logger.log("Returning  Applicants State Of Residence is "+ApplicantsStateOfResidence);
return ApplicantsStateOfResidence;

validationError

通过在扩展下拉列表中选择​ Core ​并为数据元素类型选择​ 自定义代码,配置了​ ValidationError ​数据元素,如下面的屏幕快照所示

验证错误

编写了以下自定义代码以设置validationError数据元素值。

var validationError = "";
// Using GuideBridge API to access adaptive forms fields using the fields SOM expression
var tel = guideBridge.resolveNode("guide[0].guide1[0].guideRootPanel[0].telephone[0]");
var email = guideBridge.resolveNode("guide[0].guide1[0].guideRootPanel[0].email[0]");

_satellite.logger.log("Got tel in Tags custom script "+tel.isValid)
_satellite.logger.log("Got email in Tags custom script "+email.isValid)

if (tel.isValid == false) {
  validationError = "error: telephone number";
  _satellite.logger.log("Validation error is "+ validationError);
}

if (email.isValid == false) {
  validationError = "error: invalid email";
  _satellite.logger.log("Validation error is "+ validationError);
}

return validationError;

后续步骤

创建规则

recommendation-more-help
4859a77c-7971-4ac9-8f5c-4260823c6f69