First off, I’m very new to custom coded actions and coding in general. Very little experience at all.
I’ve looked over lots of documentation and can’t seem to get this to work.
I’d like to include a deal property in a custom coded action. I’ve added the property to the list of properties to include and given it a key. I’ve referenced this in the code (shown below) the way this article says to.
However, I’m getting the following error:
2023-05-24T20:52:21.317Z ERROR Invoke Error {"errorType":"ReferenceError","errorMessage":"event is not defined","stack":["ReferenceError: event is not defined"," at Object.main (/var/task/file.js:11:13)"," at Runtime.exports.hubspot_handler [as handler] (/var/task/hubspotHandler.js:6:21)"," at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1086:29)"]}
“event is not defined” and it’s pointing to the const ein = event.inputFields[‘ein’].
What am I missing here? I’ve copied and pasted directly from articles, tutorials, and code examples.
var axios = require('axios');
function main(){
const ein = event.inputFields['ein'];
var data = JSON.stringify({
"ticket": {
"comment": {
"body": `The smoke is very colorful. \n EIN: ${ein}`
},
"priority": "urgent",
"subject": "My printer is on fire!"
}
});
var config = {
method: 'POST',
url: 'https://example.zendesk.com/api/v2/tickets',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <token>', // Base64 encoded "username:password"
},
data : data,
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
})}
module.exports.main = main;
