APIs & Integrations

HKotha
Member

Hubspot Global Variables

SOLVE

Hello Everyone!

I've some Custom Coded Actions that contain an External API Endpoint defined as a variable in the Code. 

I'm doing this in the Sandbox, and the External API Endpoint corresponds to the system's QA instance.

If we decide to manually create this Workflow in Production, it's fairly straightforward. We'll create a Workflow, Custom Coded Action and replace the API Endpoint to refer to the corresponding Production instance.

 

But if we decide to use some Scripts to move the workflow to Production, We still have to manually replace the API Endpoint to refer to the corresponding Production instance.

So my Question is, is there a concept called Global variables in Hubspot where I can refer to that in the code instead of hardcoding the API Endpoint in the code? 
Such that the Global Variable of the Hubspot Sandbox will have the External API Endpoint of 'QA instance,' and the Global Variable of the Hubspot Production will have the External API Endpoint of the Production instance.


Thank you!



0 Upvotes
1 Accepted solution
MichaelMa
Solution
Contributor

Hubspot Global Variables

SOLVE

Unfortunately, no. I've run into the same issues.

 

What I ended up doing is creating a Custom Coded action at the very beginning acting as a "config". It has output variables which can then be accessed by other Custom Coded actions or even things like sending a slack message (superhelpful to have something like "workflow name" in my config so I can copy/paste the message to other workflows without having to edit them to refer to itself).

 

Eg,

 

exports.main = async (event, callback) => {
  //const environment = "staging"
  const environment = "production"

  let pipeline = "12345"
  if (environment == "staging")
    pipeline = "67890"

  const workflowName = "WORKFLOW NAME" 

  callback({
    outputFields: {
      settingPipeline: pipeline,
      settingEnvironment: environment,
      settingWorkflowName: workflowName,
    }
  });
}

 

Previously, I also tried to have a "mode" for debugging (basically switches to whether or not it outputs the payload or executes the api request) in the config above but decided to move that to each custom coded action because editing config constantly got annoying.

 

View solution in original post

0 Upvotes
1 Reply 1
MichaelMa
Solution
Contributor

Hubspot Global Variables

SOLVE

Unfortunately, no. I've run into the same issues.

 

What I ended up doing is creating a Custom Coded action at the very beginning acting as a "config". It has output variables which can then be accessed by other Custom Coded actions or even things like sending a slack message (superhelpful to have something like "workflow name" in my config so I can copy/paste the message to other workflows without having to edit them to refer to itself).

 

Eg,

 

exports.main = async (event, callback) => {
  //const environment = "staging"
  const environment = "production"

  let pipeline = "12345"
  if (environment == "staging")
    pipeline = "67890"

  const workflowName = "WORKFLOW NAME" 

  callback({
    outputFields: {
      settingPipeline: pipeline,
      settingEnvironment: environment,
      settingWorkflowName: workflowName,
    }
  });
}

 

Previously, I also tried to have a "mode" for debugging (basically switches to whether or not it outputs the payload or executes the api request) in the config above but decided to move that to each custom coded action because editing config constantly got annoying.

 

0 Upvotes