I’m pretty new to programming and working on connecting HubSpot to Google Data Studio through Google Apps Script and Sheets. When I pull deal data from HubSpot, I keep getting numeric IDs for things like deal stages and pipelines instead of their actual readable names. For example, instead of seeing “Proposal Sent” I get something like “12345678”. Other fields like deal names work fine and show the correct text.
function fetchContracts() {
var authService = getAuthService();
var requestHeaders = {headers: {'Authorization': 'Bearer '+ authService.getAccessToken()}};
var continueLoop = true;
var pageOffset = 0;
var contractsList = Array();
while(continueLoop) {
var apiEndpoint = BASE_URL + "/deals/v1/deal/paged?properties=dealstage&properties=pipeline&properties=projectname&properties=value&properties=title&properties=category&limit=100&offset="+pageOffset;
var apiResponse = UrlFetchApp.fetch(apiEndpoint, requestHeaders);
var parsedData = JSON.parse(apiResponse.getContentText());
continueLoop = parsedData.hasMore;
pageOffset = parsedData.offset;
parsedData.deals.forEach(function(contract) {
var stageValue = (contract.properties.hasOwnProperty("dealstage")) ? contract.properties.dealstage.value : 0;
var pipelineValue = (contract.properties.hasOwnProperty("pipeline")) ? contract.properties.pipeline.value : 0;
var projectName = (contract.properties.hasOwnProperty("projectname")) ? contract.properties.projectname.value : "unknown";
var contractValue = (contract.properties.hasOwnProperty("value")) ? contract.properties.value.value : 0;
var contractTitle = (contract.properties.hasOwnProperty("title")) ? contract.properties.title.value : 0;
var contractCategory = (contract.properties.hasOwnProperty("category")) ? contract.properties.category.value : 0;
contractsList.push([stageValue,pipelineValue,projectName,contractValue,contractTitle,contractCategory]);
});
}
return contractsList;
}
How can I modify this to get the display labels instead of these internal ID numbers?