Workflow javascript to parse first name and last name fields from query to add as seperate columns in a table

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 ('primary_contact')) {firstname =,' '))} 
else{ firstname = //will parse later 
query4.push(["firstname" , firstname], ["lastname",lastname]);


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 key does not exist I'll parse the project name rather then primary contact name

Solved, Isaac is the best!!!
here is the code to separate the first and last name based on the "Primary_Contact" key if available or the job name if not.

var firstname = ''
var lastname = ''
if ('primary_contact')) {firstname =,' '))
lastname =' ')+1)}
else {firstname =,' '));
lastname =' ')+1)}
var fullName =
fullName.firstname = firstname;
fullName.lastname = lastname;
return fullName

1 Like