3

this is a beginner AmpScript question. I can't seem to even get past "Step One" in my attempt to learn AmpScript.

I am trying to follow the "AmpScript 101 tutorial" located here

I am trying to set a list of variables per the first example in the tutorial:

    %%[
Var @memid, @fname, @lname, @prefname, @address, @zip, @mempref, @plat
Set @memid = MemberID
Set @fname = FirstName
Set @lname = LastName
Set @prefname = PrefName
Set @address = Address
Set @zip = Zip
Set @mempref = MemPref
Set @plat = Plat

]%%

And the following code works fine with only the variable "@memid" set:

%%[
Var @memid, @fname, @lname, @prefname, @address, @zip, @mempref, @plat
Set @memid = MemberID

]%%

Then, when I set the variable "@fname," the code also works fine.

   %%[
    Var @memid, @fname, @lname, @prefname, @address, @zip, @mempref, @plat
    Set @memid = MemberID
    Set @fname = FirstName

    ]%%

Then, again, when I set the variable "@lname" the code also works.

 %%[
    Var @memid, @fname, @lname, @prefname, @address, @zip, @mempref, @plat
    Set @memid = MemberID
    Set @fname = FirstName
    Set @lname = LastName

    ]%%

But if I try to set any more than those three variables, my code completely breaks. Why is this happening? I've searched and searched for an answer, and I can't seem to figure out what's going on.

For example, this code will throw an error:

%%[
    Var @memid, @fname, @lname, @prefname, @address, @zip, @mempref, @plat
    Set @memid = MemberID
    Set @fname = FirstName
    Set @lname = LastName
    Set @prefname = PreferredName


    ]%%

(The error is "The SET variable value expresion(sic) is invalid. See inner exception for detail. Script: Set @prefName = PreferredName Variable Name: @prefname The SET variable value expresion is invalid. See inner exception for detail. Script: Set @prefname = PreferredName Variable Name: @prefname Index: 4459 ListID: 452"

Or, when I try to set any other variable such as @address, @zip, @mempref, or @plat, I get a similar error.

Also, any other random variable that I attempt to set creates the same error. For example, this code:

%%[
    Var @grapefruit
    Set @grapefruit = CitrusFruit

    ]%%

The code above produces this error: "The SET variable value expresion(sic) is invalid. See inner exception for detail. Script: Set @grapefruit = CitrusFruit Variable Name: @grapefruit Index: 4312 ListID: 452"

I can't seem to successfully set ANY variables at all apart from three specific ones: @memid, @fname, @lname

The fact that I am only able to set three specific variables makes no sense to me. But I can't seem to spot what my error is, or where I'm going wrong, and I can't figure out why code in a basic 101 tutorial would not work for me. This is probably a silly, stupid question with an obvious answer, but I am truly stuck and cannot find a way to get out of the gate with this.

Information about my development environment: I am using the SalesForce Marketing Cloud's development environment. I'm working under Email > Content > Template-based email. I have tried writing this same code in a straight HTML email, and I am getting precisely the same errors regardless of whether I'm using straight-up HTML or a template, but am currently working with template-based email. To see if the code is working, I am clicking "Send Preview," selecting a test recipient, and then clicking on "Generate Preview" which then either generates a functioning preview of the e-mail (with variables @memid, @fname, or @lname) or an error message (with any other attempt to set any other variable)

  • Have you set up your profile attributes? – Kelly J Andrews Jul 29 '14 at 13:42
3

I think what you are running into, is that your account is not yet fully built out.

The reasone why MemberID, FirstName, LastName all work, is that the account already has those set up as profile attributes, and are listed as personalization strings

A profile attribute contains information to characterize a subscriber profile. For example, each subscriber may be asked to provide their gender, birth date, and email address. By default, every account has three profile attributes: Full Name, Email, and User Defined (which is intended as a generic attribute that you can use as needed). You cannot modify these attributes.

A preference attribute characterizes how a subscriber prefers to receive email. These are specified as "yes or no" choices to a declarative statement. For example: "The subscriber prefers to receive email as HTML."

First you must create the profile or preference attribute in your account so there is a place for the system to store the data. You also specify whether an attribute is required information for every subscriber and whether subscribers can see and edit their own attributes in the Profile Center (a link to the Profile Center is included in every email). You can also specifiy profile attributes when you import a subscriber list. See Subscribers for more information.

  1. Click the Subscribers tab.
  2. Click Profile Management or Preference Management.
  3. Click Create Attribute, which opens the Attribute Properties dialog box.
  4. Define the properties for this attribute.
  5. Click OK in the Attribute Properties dialog box when done.

Note: If you marked the new attribute as a required field, all subscriber imports now must include this field. You may want to include a default value so that records can be saved even if a value isn't provided.

You will then be able to access those properties in your AMPscript.

  • Great, make sure to check this as answered! – Kelly J Andrews Jul 29 '14 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.