Get Info via Corporate Number API
Stores the “company name”, “postal code”, “domestic address” of the Corporate Number system respectively into the data item, and stores its communication log in a String type data item.
Configs
  • A: Set Application Id (Access Key) for Houjin Web-API *#{EL}
  • B: Select STRING/SELECT for a Corporate Number *
  • C: Select STRING DATA for Corporate Name (update)
  • D: Select STRING DATA for Corporate PostCode (update)
  • E: Select STRING DATA for Corporate Address (update)
  • X: Select STRING DATA for Access Log (update)
Script (click to open)
// Get Info via Corporate Number API v1 (ver. 20161102)
// (c) 2016, Questetra, Inc. (the MIT License)

//// == 工程コンフィグの参照 / Config Retrieving ==
var appId   = configs.get( "conf_AppId" );
var dataIdB = configs.get( "conf_DataIdB" ); // (returns Number)
var dataIdC = configs.get( "conf_DataIdC" ); // (returns Number)
var dataIdD = configs.get( "conf_DataIdD" ) + "";
var dataIdE = configs.get( "conf_DataIdE" ) + "";
var dataIdX = configs.get( "conf_DataIdX" ) + "";

//// == ワークフローデータの参照 / Data Retrieving ==
var corporateNumber = "";
if( data.get( dataIdB ) instanceof java.util.ArrayList ){
  corporateNumber = data.get( dataIdB ).get(0).getValue() + "";
}else if( data.get( dataIdB ) instanceof java.lang.String ){
  corporateNumber = data.get( dataIdB ) + "";
}

//// == 演算 / Calculating ==
var accessLog = "";
var uri = "https://api.houjin-bangou.nta.go.jp/1/num";
var response = httpClient.begin()
  .queryParam( "id", appId )
  .queryParam( "number", corporateNumber )
  .queryParam( "type", 12 ) // Response Format: XML
  .queryParam( "history", 0 )
  .get( uri ); 
accessLog += "---GET request--- " + response.getStatusCode() + "\n";
accessLog += response.getResponseAsString() + "";

var responseXml = response.getResponseAsString() + "";
responseXml = responseXml.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); 
// E4X (ECMAScript for XML) bug 336551
var xmlObj = new XML( responseXml );
var responseName = xmlObj.corporation[0].name + "";
var responsePostCode = xmlObj.corporation[0].postCode + "";
var responseAddress = xmlObj.corporation[0].prefectureName + "";
responseAddress += xmlObj.corporation[0].cityName + "";
responseAddress += xmlObj.corporation[0].streetNumber + "";

//// == ワークフローデータへの代入 / Data Updating ==
retVal.put( dataIdC, responseName );
if( dataIdD !== "" ){
  retVal.put( dataIdD, responsePostCode );
}
if( dataIdE !== "" ){
  retVal.put( dataIdE, responseAddress );
}
if( dataIdX !== "" ){
  retVal.put( dataIdX, accessLog );
}

Download

2020-10-20 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/corpnumberapi-getinfo/
The Addon-import feature is available with Professional or Enterprise edition.

Notes

  • It requires completion of “Procedure of Application ID issuance” at Corporate Number system Official Web site (which is written in Japanese only) in advance
  • Error detection calculation by Check Digit for the 13 digits of Corporate Number will not be performed

Capture

See also

%d bloggers like this: