sure, let me show you how to set up the custom code action with some screenshots.
The most important stuff is the following:
Language: Python 3.9
Properties to include: Choose the property that holds your Full Name values and give it key input_string
Code: Copy and paste the provided code
Data output: Create two data outputs as string values and call the first_name and last_name
You then can test it with a contact.
To use it in the First Name and Last Name properties, create two additional workflow actions with Copy Property Value. Here you can copy the value from the output strings to the respective property.
If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it.
sure, let me show you how to set up the custom code action with some screenshots.
The most important stuff is the following:
Language: Python 3.9
Properties to include: Choose the property that holds your Full Name values and give it key input_string
Code: Copy and paste the provided code
Data output: Create two data outputs as string values and call the first_name and last_name
You then can test it with a contact.
To use it in the First Name and Last Name properties, create two additional workflow actions with Copy Property Value. Here you can copy the value from the output strings to the respective property.
If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it.
Custom code / Format Data - split full name property
resolver
Hi Christoph, I have done as you show in the screenshots and get this error message :
Property to include in code is input_string My two outputs are first_name, last_name Language is python 3.9 and I have the property correctly mapped to include in code. Copied and pasted verbatim from above.
[ERROR] AttributeError: 'NoneType' object has no attribute 'split'
Traceback (most recent call last):
File "/var/task/hubspotHandler.py", line 4, in hubspot_handler
return file.main(event)
File "/var/task/file.py", line 5, in main
name_list = full_name.split(" ")
Memory: 37/128 MB
Runtime: 10.59 ms
Custom code / Format Data - split full name property
resolver
@ChrisoKlepke There are some names that have more than one word, so I changed the code so the first name will be the first word, but the last name will be the rest
Custom code / Format Data - split full name property
resolver
@ShlomiGani yeah, I was expecting such a problem. The issue I see is that you never know if it is two first names or last names. Maybe depending on the culture you're operating in, one or the other is more likely. But in any case: The way you're suggesting makes sure nothing gets lost.
The other approach could be to write an if condition in the code that returns the main function and notifies a team member to take care of that manually. Of course, doesn't scale that well.
What I'm trying to say is that no solution is entirely foolproof and there are advantages and disadvantages to everything. Thank you for the feedback and conversation, though.
what is it that you need to split and what results do you need. For example, in this short Python code for a custom code action, we use an input field (assuming it is a string) and split it at spaces. The result then would be a list. So if the input string is:
"Never gonna give you up Never gonna let you down"