Loading
關於 Salesforce Data 360
目錄
選取篩選

          沒有結果
          沒有結果
          以下是搜尋小祕訣

          檢查關鍵字的拼字。
          使用較常見的搜尋字詞。
          選取較少篩選條件以擴大您的搜尋。

          搜尋所有 Salesforce 說明
          以 APEX 取得預估

          以 APEX 取得預估

          使用 Apex 程式碼可從模型產生器中的無程式碼模型取得預估、首要因素和指示。

          可叫用動作

          若要將預測模型與 Apex 搭配使用,請使用此方法建立可叫用動作。此方法會建立可叫用動作,將輸入資料提供給預測模型。它會觸發模型要求並處理傳回的輸出,包括預估、首要因素和處方 (建議動作)。

          Invocable.Action.createCustomAction

          REST 要求

          當啟用模型時,會自動建立可叫用動作,並可在「流程」或 Apex 中使用。在 Apex 中使用此可叫用動作時,您可能需要使用此 REST 端點取得輸入參數。

          GET /services/data/v63.0/actions/custom/cdpMlPrediction/{ModelIdOrName}
          備註
          備註 您可以使用預測模型名稱 (此範例) 或模型識別碼 (API 名稱)。某些 API 也需要模型 API 名稱「{ModelIdOrName}」。您可以在模型詳細資料頁面的模型產生器中找到模型的 API 名稱。
          模型詳細資料頁面會顯示模型 API 名稱。

          讓我們瞭解一下如何針對「已購買預估」模型使用 REST 要求。

          GET /services/data/v63.0/actions/custom/cdpMlPrediction/Predicted_Purchased_CM_12l_YSs01128465

          該要求會從可叫用動作 (例如模型輸入參數) 取得相關的中繼資料。

          
          {
          "inputs" : [ 
          {
              "label" : "Top Predictors",
              "name" : "maxTopFactors",
              "type" : "INTEGER"
            }, 
          {
              "label" : "Top Prescriptions",
              "name" :  "maxPrescriptions",
              "type" : "INTEGER"
            },
          {
              "label" : "Lead Source",
              "name" : "param_Lead_Source_c__c",
              "type" : "STRING"
            }, 
          {
              "label" : "Industry",
              "name" : "param_Industry_c__c",
              "type" : "STRING"
            }, 
          {
              "label" : "Title",
              "name" : "param_Title_c__c",
              "type" : "STRING"
            }, 
          {
              "label" : "Response Time From Assignment",
              "name" : "param_Response_Time_From_Assignment_c__c",
              "type" : "DOUBLE"
            }, 
          {
              "label" : "No. of Employees",
              "name" : "param_No_of_Employees_c__c",
              "type" : "DOUBLE"
            }, 
          {
              "label" : "Response Time from Creation",
              "name" : "param_Response_Time_from_Creation_c__c",
              "type" : "DOUBLE"
            } ]
          }

          適用於預估的 Apex

          接著您可以使用 Apex 程式碼叫用「已購買的預估」模型,以提供預估、首要因素和指示。

          Invocable.Action action = Invocable.Action.createCustomAction('cdpMlPrediction', 'Predicted_Purchased_CM_12l_YSs01128465');
                  action.setInvocationParameter('param_Industry_c__c', 'High Tech');
                  action.setInvocationParameter('param_No_of_Employees_c__c', 100);
                  action.setInvocationParameter('param_Lead_Source_c__c', 'Chat');
                  action.setInvocationParameter('param_Response_Time_from_Creation_c__c', 100);
                  action.setInvocationParameter('param_Response_Time_From_Assignment_c__c', 300);
                  action.setInvocationParameter('maxTopFactors', 3);
                  action.setInvocationParameter('maxPrescriptions', 3);
                  List<Invocable.Action.Result> results = action.invoke();
                  if (results.size() > 0 && results[0].isSuccess()) {
                  System.debug('Prediction =' + results[0].getOutputParameters().get('prediction')); //output will be in the same data type as the model output
                  System.debug('Top Factors =' + results[0].getOutputParameters().get('factors')); //output is a custom APEX Type ConnectAPI.CdpMlPredictionContribution
                  System.debug('Prescriptions =' + results[0].getOutputParameters().get('prescriptions')); //output is a custom APEX Type ConnectAPI.CdpMlPredictionContribution
                  }
          
           
          正在載入
          Salesforce Help | Article