EDIT
Based on your answer (which has been deleted as it was posed as a question/comment and not an answer) I believe the issue you had in your new code was that you did not define the @Email
variable. See updated code below. If this does not answer your issue still, please let me know what error you are getting when you preview the email with that code in it.
I believe your issue is that you are not including a primary key for it to match on in your upsertDE function. That combined with that you do not need to use the v()
function inside of AMPscript blocks is likely what is causing issues. Also, your substring for last name is not correct. I added in the correct beginning and ending of your substring for that as well.
See below for example code: (replace "PrimaryKey"
and @PrimaryKey
with your primary key name and values.)
%%[
var @Name, @first_name, @last_name, @FirstName, @LastName
set @Email = AttributeValue('emailaddr')
set @Name = AttributeValue('Name')
set @first_name = substring(@Name,1,subtract(indexOf(@Name,' '),1))
set @Last_name = substring(@Name,ADD(indexOf(@Name,' '), 1),Length(@Name))
set @FirstName = @first_name
set @LastName = @last_name
UpsertDE('AMPscript Functions 1', 1, "Email", @Email, 'FirstName', @first_name, 'LastName', @last_name)
]%%
I am not sure why you are duplicating FirstName and LastName vars, when you can just name the initial vars differently. See below for sample of what I mean:
%%[
var @Name, @first_name, @last_name, @FirstName, @LastName
set @Email = AttributeValue('emailaddr')
set @Name = AttributeValue('Name')
set @FirstName = substring(@Name,1,subtract(indexOf(@Name,' '),1))
set @LastName = substring(@Name,ADD(indexOf(@Name,' '), 1),Length(@Name))
UpsertDE('AMPscript Functions 1', 1, "Email", @Email, 'FirstName', @FirstName, 'LastName', @LastName)
]%%