Retrieving all service details through public API
Jump to navigation
Jump to search
The javascript below retrieves all services through the available API and per retrieved service, the details of the service is retrieved through an additional API call.
var getObjectByValue = function(array, key, value) { return array.filter(function(object) { return object[key] === value; }); }; var getServicePartValue = function(array, partname) { var partarray = array.filter(function(object) { return object.name === partname; }); if (partarray.length) { return partarray[0].value; } return ''; }; var allServices = JSON.parse(CommonInterface.callWebservice('Services: get all via public api', {})); var allApprovalMappings = JSON.parse(CommonInterface.getAllParameterEntries('ScApprovaMapping')); var serviceGuid = ''; for (var i = 0; i < allServices.length; i++) { serviceGuid = allServices[i].guid; serviceDetails = JSON.parse(CommonInterface.callWebservice('Services: get service details via public api', { 'ServiceGuid': serviceGuid })); if (serviceDetails) { var overviewparts = []; // merge all tabs together for easier browsing for (var j = 0; j < serviceDetails.datatabs.length; j++) { if (serviceDetails.datatabs[j].name === "Overview") { overviewparts = serviceDetails.datatabs[j].parts; } } // Example line how to get the field Competence Center from the returned details var CompetenceCenter = getServicePartValue(overviewparts, "Competence Center"); } } return 1;