Hello everyone !
First and foremost, thank you in advance for the attention you’ll give to my issue.
I’m reaching out because I’m currently setting up a workflow.
I need to retrieve the company’s properties in order to make a POST request to my server to use them.
When I test my code via the HubSpot interface by adding test values, everything works perfectly. However, when I trigger my workflow upon form submission, I can’t retrieve the desired data.
Could you please take a look at my code? I’m attaching a screenshot at the end (from VsCode for better readability).
A small detail that might be important: the form that triggers the workflow has only one field: SIRET. The other properties are added through a GET request. This works flawlessly.
Thank you in advance!
Akram
Hi, @Akram_Boukhers
Thanks for your question. Were you able to make any progress on this project? If not, can you add your code sample and any error messages you receive, to your post directly? You can use the code block tool to help with formatting.
This is because, it’s hard to impossible for our community members to diagnose code challenges from screenshots.
Best,
Jaycee
Thank you for your message Jaycee !
No problem, I pass the code using the appropriate tool.
I have no error message, the concern is that the 'datas' object returned by my outputFields is systematically empty when my workflow is running, whereas when I test this same workflow the 'datas' object has the values company properties as expected...
Here is my custom code that fires in the workflow :
const axios = require('axios');
exports.main = (event, callback) => {
setTimeout(() => {
// Récupérez les données du workflow
const siret = event.inputFields['siret'] || "";
const rna = event.inputFields['rna'] || "";
const nom = event.inputFields['nom'] || "";
const dateCreation = event.inputFields['dateCreation'];
const adresse = event.inputFields['adresse'] || "";
const codePostal = event.inputFields['codePostal'] || "";
const ville = event.inputFields['ville'] || "";
const companyData = {
"siret": siret,
"rna": rna,
"nom": nom,
"dateCreation": dateCreation,
"adresse": adresse,
"codePostal": codePostal,
"ville": ville
};
const SERVER_URL = 'https://784d-130-180-212-98.ngrok-free.app/receiveCompanyData';
axios.post(SERVER_URL, companyData).then(response => {
const responseData = response.data;
callback({
outputFields: {
datas: companyData,
success: true,
message: 'Data sent successfully',
responseData: responseData
}
});
}).catch(error => {
callback({
outputFields: {
success: false,
message: `Error sending data: ${error.message}`
}
});
});
}, 10000); // Attendre 10 secondes
};