APIs & Integrations

DTeam8
Member

API for CRM Card to get Portal ID

Hi, I have created 1 CRM card using public app at Hubspot Developer account and install it to one of our Hubspot Portal successfully. 

 

Refer by: https://developers.hubspot.com/docs/api/crm/extensions/crm-cards


The CRM card also loaded on the deal page without any error. I want to show portal ID on the deal CRM card,  I have used following code to get Portal ID

const portalId= context.params.portalId;

But it getting undefined,

 

DTeam8_0-1701938452042.png

 

 

Other than this the following default values getting properly

const ObjectId= context.params.associatedObjectId;

const ObjectType= context.params.associatedObjectType;

 

how can I get portal ID at CRM card?

Please let us know as soon as possible,

 

Thanks
Thanks

0 Upvotes
5 Replies 5
DTeam8
Member

API for CRM Card to get Portal ID

Hi @Jaycee_Lewis any update here? 

0 Upvotes
DTeam8
Member

API for CRM Card to get Portal ID

Hi @Jaycee_Lewis any update here, Please upsate as soon as possible.

0 Upvotes
DTeam8
Member

API for CRM Card to get Portal ID

Hi @Jaycee_Lewis ,

 

I am requesting a json file URL, which is present in the file section of Hubspot portal where the public app is installed, and the file name is same as the portal ID.json . Once the json file content received we will display it on the CRM card, there is no issue for display the content on the CRM card, if we use static portal ID.json file in our code then it execute suceessfully and display the content on the CRM card without any error.

 

Our issue is to fetch Portal ID and with the use of that ID getting the Json file.
Here is my code please look at it and help me as soon as possibe.

 

----------------------------------------------------------------------------------------------------------


exports.main = (context, sendResponse) => {

const hs_object_id = context.params.hs_object_id;
const portalId = context.params.portalId;
var request = require("request");

var request_url_filter = 'https://'+portalId+'.fs1.hubspotusercontent-na1.net/hubfs/'+portalId+'/'+portalId+'.json';

var options = { method: 'GET',
url: request_url_filter,
json: true };

request(options, function (error, response, body) {
if (error) throw new Error(error);

var crm_quote_data = '';
if( body['deals_quotes'] !== undefined ) {

var deals_quotes = body['deals_quotes'];
var deals_quotes_len = body['deals_quotes'].length;

for(var i=0; i<deals_quotes_len; i++) {

var deal_id = deals_quotes[i].deal_id;

if( deal_id == hs_object_id ) {
crm_quote_data = deals_quotes[i].CRM_quote_data;
}

}

if( crm_quote_data == '' ) {

var results = [];
var dataObj = {
"objectId": 123,
"title": "Vendori quotes not available for this Deal, please update the JSON file. ",
"created": "2016-09-15",
"priority": "HIGH",
"project": "API",
"reported_by": "msmith@hubspot.com",
"description": "Customer reported that the APIs are just running too fast. This is causing a problem in that they're so happy.",
"reporter_type": "Account Manager",
"status": "In Progress",
"ticket_type": "Bug",
"updated": "2016-09-28"
};

results.push(dataObj);

crm_quote_data = {
"settingsAction": {
"type": "IFRAME",
"width": 890,
"height": 748,
"uri": "https://qa.vendori.com/quotes/create?opportunityId="+hs_object_id,
"label": "Create Quote"
}, results };

}

} else {

var results = [];
var dataObj = {
"objectId": 123,
"title": "404 JSON file not found, please upload the file. ",
"created": "2016-09-15",
"priority": "HIGH",
"project": "API",
"reported_by": "msmith@hubspot.com",
"description": "Customer reported that the APIs are just running too fast. This is causing a problem in that they're so happy.",
"reporter_type": "Account Manager",
"status": "In Progress",
"ticket_type": "Bug",
"updated": "2016-09-28",
"properties": [
{
"label": "Note: ",
"dataType": "STRING",
"value": "File should place on root of the file section and it's name should be "+portalId+".json"
}
]
};

results.push(dataObj);

crm_quote_data = {
"settingsAction": {
"type": "IFRAME",
"width": 890,
"height": 748,
"uri": "https://app.hubspot.com/files/"+portalId+"/",
"label": "Upload JSON File"
}, results };


}

sendResponse({body: crm_quote_data, statusCode: 201});
});

};

----------------------------------------------------------------------------------------------------------

 

Thanks

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

API for CRM Card to get Portal ID

Hey, @DTeam8 👋 Do you have any additional details you can share? Do you have a simple example of a request and response you can add as a code block here? I'm happy to do a bit more investigation into if this is the expected behaviour.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
DTeam8
Member

API for CRM Card to get Portal ID

Hi @Jaycee_Lewis ,

 

Here is request URL that I can get from CRM Extension logs - https://39664539.hs-sites.com/_hcms/api/vend-quote-v3?userId=52126082&userEmail=development@webcanop...

In request URL I can see the correct Portal ID but can't display it on the CRM card. Other properties works fine only problem is fetching Portal ID.

 

Please check the above berief and help as soon as possile.
thanks