Batch acquisition of Salesforce Customer Data

Stores business partner's ID and Name inside Salesforce respectively into data items, and stores its communication log in a String type data item.

    A. Set OAuth2 Config Name (at [OAuth 2.0 Setting])Single-line inputRequired
    B. Set Sub-Domain (https://{subdomain}.salesforce.com/)Single-line inputRequired
    C. Select STRING DATA for Choise-IDs (update)Data selectString(multiple line)Required
    D. Select STRING DATA for Labels (update)Data selectString(multiple line)Required
    X. Select STRING DATA for Access Log (update)Data selectString(multiple line)
    -variable namevariable label
    Aconf_OAuth2Set OAuth2 Config Name (at [OAuth 2.0 Setting])
    Bconf_SubDomainSet Sub-Domain (https://{subdomain}.salesforce.com/)
    Cconf_DataIdCSelect STRING DATA for Choise-IDs (update)
    Dconf_DataIdDSelect STRING DATA for Labels (update)
    Xconf_DataIdXSelect STRING DATA for Access Log (update)
    // Batch to Get Accounts from Salesforce via Salesforce REST API (ver. 20161017)
    // (c) 2016, Questetra, Inc. (the MIT License)
    
    // OAuth2 config
    // Authorization Endpoint URL: https://login.salesforce.com/services/oauth2/authorize
    // Token Endpoint URL: https://login.salesforce.com/services/oauth2/token
    // Scope: 
    // Consumer Key: (Get by Salesforce Connected App screen)
    // Consumer Secret: (Get by Salesforce Connected App screen)
    
    //// == 工程コンフィグの参照 / Config Retrieving ==
    var oauth2 = configs.get( "conf_OAuth2" );
    var subDomain = configs.get( "conf_SubDomain" );
    var dataIdC = configs.get( "conf_DataIdC" ); // (returns Number)
    var dataIdD = configs.get( "conf_DataIdD" ); // (returns Number)
    var dataIdX = configs.get( "conf_DataIdX" ) + ""; // (returns Number)
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    
    
    //// == 演算 / Calculating ==
    var accessLog = "";
    var responseJson = "";
    var token = httpClient.getOAuth2Token( oauth2 );
    
    var choiseIds = "";
    var choiseLabels = "";
    
    try{
      var uri = "https://";
      uri += subDomain;
      uri += ".salesforce.com/services/data/v37.0/query/";
    
      var response = httpClient.begin()
        .bearer(token)
        .queryParam("q", "SELECT Id, Name from Account")
        .get(uri);
      accessLog += "---GET request--- " + response.getStatusCode() + "\n";
      responseJson = response.getResponseAsString();
      if( response.getStatusCode() == 200 ){
        var jsonObj = JSON.parse( responseJson );
        for( var i = 0; i < jsonObj.records.length; i++ ){
          choiseIds += jsonObj.records[i].Id + "\n";
          choiseLabels += jsonObj.records[i].Name + "\n";
        }
      }
    }catch(e){
      accessLog += e.message + "\n";
    }
    // for Debug
    // accessLog += responseJson + "\n";
    
    //// == ワークフローデータへの代入 / Data Updating ==
    retVal.put( dataIdC, choiseIds );
    retVal.put( dataIdD, choiseLabels );
    if( dataIdX !== "" ){
      retVal.put( dataIdX, accessLog );
    }
    

    • none
    • Customer ID and Name inside Salesforce will be respectively stored in the Data Items selected at config C and D
    • Communication log will be stored in the Data Item selected at config X