CMS Development

tommitchell
Contributeur

Use CRM data in JS

Résolue

Hi - sorry if this is a daft question but I'm trying to work out how to use contact CRM data in the js part of a custom module.

 

This is a data series for a chart:

 

series: [{
name: 'sales',
data: [30,40,45,50,49,60,70,91,125]
}],

 

How can I replace a static data value with, for example, the value of:

{{ contact.tenancy_created_company }} ? I'm assuming I need to 'set' this value in the HTML/Hubl but I'm struggling to get anywhere.

 

I'd be really grateful for any help!

0 Votes
2 Solutions acceptées
Kevin-C
Solution
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Use CRM data in JS

Résolue

Hey @tommitchell 

 

You might be able to use the tojson filter to output the data needed to a global in the html/hubl. Then with your custom JS, parse and declare it to your object key.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

Voir la solution dans l'envoi d'origine

alyssamwilie
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Use CRM data in JS

Résolue

Yes, you would need to declare the data in the HTML/HUBL. Something like:

HTML/HUBL

<script>
  window.data = {
    {{ contact.tenancy_created_company|tojson }}
  }
</script>

JS

series: [{
  name: 'sales',
  data: window.data
}]

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

Voir la solution dans l'envoi d'origine

2 Réponses
alyssamwilie
Solution
Expert reconnu | Partenaire solutions Elite
Expert reconnu | Partenaire solutions Elite

Use CRM data in JS

Résolue

Yes, you would need to declare the data in the HTML/HUBL. Something like:

HTML/HUBL

<script>
  window.data = {
    {{ contact.tenancy_created_company|tojson }}
  }
</script>

JS

series: [{
  name: 'sales',
  data: window.data
}]

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
Kevin-C
Solution
Expert reconnu | Partenaire solutions
Expert reconnu | Partenaire solutions

Use CRM data in JS

Résolue

Hey @tommitchell 

 

You might be able to use the tojson filter to output the data needed to a global in the html/hubl. Then with your custom JS, parse and declare it to your object key.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev