I'm trying to use javascript on a web hook to add key value pairs for first name and last name that will be pulled from the primary contact name (if present) or from the project name if there is not a primary contact for the current Company Cam Project
- not every project contains a primary contact
- if a primary contact key is present then use the part of the primary contact before the first space and set it as firstname
- similar process to declare lastname from the section after the space
var firstname = ''
var lastname = ''
if (query4.data.hasOwnProperty('primary_contact')) {firstname = query4.data.primary_contact.name.substring(0, query4.data.primary_contact.name.indexOf(' '))}
else{ firstname = query4.data.name //will parse later
}
query4.push(["firstname" , firstname], ["lastname",lastname]);
return query4.data
needing a way of adding key value pairs into the mix for firstname and lastname. It seems to be declaring them now and adding the string values to them but how can i add this data into the response to be used later for the insert to table on the next step?
then if the query4.data.primary_contact
key does not exist I'll parse the project name rather then primary contact name