[整合]{class="badge positive"}

建立資料元素

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

我們在Tags屬性中新增了兩個新資料元素(ApplicationsStateOfResidence和validationError)。

最適化表單

ApplicantStateOfResidence

在延伸功能下拉式清單中選取​ 核心,並選取資料元素型別的​ 自訂程式碼,以設定​ ApplicantStateOfResidence ​資料元素,如下方熒幕擷取畫面所示
applicant-state-residence

下列自訂程式碼是用來從​ 狀態 ​最適化表單欄位擷取值。

// 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

在延伸功能下拉式清單中選取​ 核心,並為資料元素型別選取​ 自訂程式碼,以設定​ 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