Table of Contents

Search

  1. Preface
  2. Introduction to Business Entity Services
  3. Enterprise Java Bean Business Entity Service Calls
  4. Representational State Transfer Business Entity Service Calls
  5. Simple Object Access Protocol Business Entity Service Calls
  6. Services for Cross-reference Records and BVT Calculations
  7. Supporting Corporate Linkage Service
  8. External Calls to Cleanse, Analyze, and Transform Data
  9. Using REST APIs to Add Records
  10. Using REST APIs to Upload Files

JavaScript Example

JavaScript Example

The resource kit has sample Java source code that shows how to make REST business entity service calls.
The sample code is in the following file:
<
MDM Hub installation directory
>\hub\resourcekit\samples\COS\source\resources\webapp\rest-api.html
The following code shows REST API calls to create a person root record, add multiple child records, delete one child record, and then delete the person record and all child records:
<html> <head> <script type="text/javascript" src="jquery-1.11.1.js"></script> <script type="text/javascript" src="cs-client.js"></script> </head> <body> <script type="text/javascript" language="javascript"> $(document).ready(function () { $("#run").click(function () { log = function(msg, json) { $('#log').before("<hr/><b>" + msg + "</b>"); $('#log').before("<pre>" + JSON.stringify(json, undefined, 2) + "</pre>"); }; CSClient.createCo( "/Person", { firstName: "John", lastName: "Smith" }, { systemName: "Admin" } ).then( function (result) { log("PERSON CREATED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 1 } ); } ).then( function (result) { log("READ CREATED PERSON:", result); return CSClient.updateCo( "/Person/" + result.rowidObject.trim(), { genderCd: { genderCode: "M" }, TelephoneNumbers: { item: [ { phoneNumber: "111-11-11" }, { phoneNumber: "222-22-22" } ] } }, { systemName: "Admin" } ); } ).then( function (result) { log("PERSON UPDATED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 3, readSystemFields: true } ); } ).then( function (result) { log("READ UPDATED PERSON:", result); return CSClient.deleteCo( "/Person/" + result.rowidObject.trim() + "/TelephoneNumbers/" + result.TelephoneNumbers.item[0].rowidObject.trim(), { systemName: "Admin" } ); } ).then( function (result) { log("TELEPHONE DELETED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 3 } ); } ).then( function (result) { log("READ PERSON AFTER TELEPHONE IS DELETED:", result); return CSClient.deleteCo( "/Person/" + result.rowidObject.trim(), { systemName: "Admin" } ); } ).then( function (result) { log("PERSON DELETED:", result); return CSClient.readCo( "/Person/" + result.Person.rowidObject.trim(), { depth: 1, recordStates: "ACTIVE,PENDING,DELETED", readSystemFields: true } ); } ).then( function (result) { log("READ PERSON AFTER DELETE (HSI -1):", result); } ); }); }); </script> <input type="button" id="run" value="Run..."/> <p/> <div id="log"></div> </body> </html>

0 COMMENTS

We’d like to hear from you!