⚙ Operations Hub

PBaxter
Colaborador(a)

Text to Value

resolver

Hi,

 

Using Ops Hub to transform some incoming string data (in a text field) like:

 

"25% increase"

"-10% decrease"

 

I can easily use the replace function to strip the " % increase" and " % decrease" text to create data "25" and "10"

 

But then I want to copy that output into a number field, and I can't see a function in Ops Hub to do a simple text to number transformation - e.g. value() or parseInt()... etc

 

Any suggestions?

 

Thanks!

0 Avaliação positiva
1 Solução aceita
Teun
Solução
Especialista reconhecido(a) | Parceiro Diamante
Especialista reconhecido(a) | Parceiro Diamante

Text to Value

resolver

Or with even less code:

exports.main = async (event, callback) => {
  callback({
    outputFields: {
      newNumberValue: Number(event.inputFields['formula_result_output'])
    }
  });
}


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


Exibir solução no post original

4 Respostas 4
Teun
Especialista reconhecido(a) | Parceiro Diamante
Especialista reconhecido(a) | Parceiro Diamante

Text to Value

resolver

@PBaxter You could achieve this with a coded action, simply use the value you got from your format data action in your coded action and try the following:

exports.main = async (event, callback) => {
  const valueToConvert = event.inputFields['formula_result_output'];
  const newNumberValue = Number(valueToConvert);
  callback({
    outputFields: {
      newNumberValue: newNumberValue
    }
  });
}

 

Schermafbeelding 2022-11-03 om 20.11.14.png



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Avaliação positiva
Teun
Solução
Especialista reconhecido(a) | Parceiro Diamante
Especialista reconhecido(a) | Parceiro Diamante

Text to Value

resolver

Or with even less code:

exports.main = async (event, callback) => {
  callback({
    outputFields: {
      newNumberValue: Number(event.inputFields['formula_result_output'])
    }
  });
}


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


PBaxter
Colaborador(a)

Text to Value

resolver

You guys on here are so awesome. I'd wondered if a bit of code could address this, but it would have taken me hours to work out how to do those input/output pieces - thanks so much for the screenshots!

 

I have my solution working now after a couple of hours doing and testing the workflows.  

 

Thanks again. 

0 Avaliação positiva
christopher-RVO
Conselheiro(a) de destaque | Parceiro Diamante
Conselheiro(a) de destaque | Parceiro Diamante

Text to Value

resolver

@PBaxter  HubSpot will prevent you from copying fields of different types over to one another. 

Alternatively, you could change your initial string data to be in positive or negative value formats - and change the text field to a number instead. you could assume that positive values mean increases and negative values mean decreases. That would then allow you to copy the value to a number field.


Christopher Barnett - VP of Revenue at Aptitude 8


0 Avaliação positiva