機械翻訳について

salesMLQuerySimilarRecords APIのグローバル関数の作成

salesMLQuerySimilarRecords APIのグローバル関数を作成する方法を次に示します。

  1. アクティブなサンドボックスで続行し、「構成」「アプリケーション・コンポーザ」「共通設定」「グローバル関数」にナビゲートします。
  2. グローバル関数アイコンをクリックします。
  3. 「グローバル関数の作成」ページで、関数名を入力します。 たとえば、invokeSalesMLSimilarRecordsQueryAPIのようにします。

    Groovyで同じグローバル関数名を式タイプ・フィールドに使用してください。

  4. 「戻り値」に「String」を選択します。
  5. 次のパラメータを追加します。
    • 名前: useCaseCode : String。
    • 名前: objectPKName : String。
    • 名前: recordPKValue : Long(整数)。

    類似アカウント問合せAPIのグローバル関数を作成します。
  6. 次のGroovyコードを「スクリプトの編集」フィールドに追加します。
    def inputMap = [:];
    def accountNames = "";
    def debugLog = "";
    if(recordPKValue != null) {
      try {
        debugLog += "Primary Key:"+recordPKValue;
        def wsRequest = adf.webServices.salesMLQueryAPISimilarRecords;
        def httpHeaders = ['Content-Type': 'application/json', 'Accept-Encoding': 'text/plain']
        wsRequest.requestHTTPHeaders = httpHeaders;
        inputMap.put("UseCaseCode",  useCaseCode);
        inputMap.put("QueryMetadata",  "whereClause:".concat(objectPKName).concat("=").concat(recordPKValue.toString()).concat(";numberOfRows:5"));
        def partyIds = "";
        debugLog += "GOING TO INVOKE SALESML API: ";
        def wsResponse = wsRequest.POST(inputMap);
        debugLog += "SALESML API INVOKED: ";
        for(similarAccount in wsResponse) {
          if(partyIds == "") {
            partyIds += similarAccount.PARTYID;
          } else {
            partyIds += ","+similarAccount.PARTYID;
          }
        }
        if(partyIds != "") {
          debugLog += "START ACCOUNTS GET PREP: ";
          def wsRequest2 = adf.webServices.Acconts_GET;
          def httpHeaders2 = ['REST-Framework-Version': '2'];
          wsRequest2.requestHTTPHeaders = httpHeaders2;
          def queryParams = ['q':'PartyId IN ('+partyIds+')'];
          wsRequest2.dynamicQueryParams = queryParams;
          debugLog += "GOING TO INVOKE ACCOUNTS GET: ";
          def accounts = wsRequest2.GET();
          debugLog += "INVOKED ACCOUNTS GET: ";
          def count = 0;
          for(account in accounts.items) {
            if(count == 0) {
              accountNames += account.OrganizationName;
            } else {
              if(count<5){
                accountNames += ",\n"+account.OrganizationName;
              } else {
                break;
              }
            }
            count++;
          } 
        }
      } catch (e) {
        debugLog += e.getMessage();
        accountNames = debugLog;
      }
    } else {
      accountNames = "Not Available";
    }
     
    if(accountNames == "") {
      accountNames = "Not Available";
    }
     
    return accountNames;
    
  7. 「検証」をクリックします。
    グローバル関数のGroovyスクリプトを入力します。
  8. 「保存して閉じる」をクリックします。
    Groovyに警告が表示される場合があります。 これらの警告を無視し、「はい」をクリックしてスクリプトを保存します。
    警告を無視してスクリプトを保存します。