Using math operators to manipulate output value of an S-Tag (in an Email)

Options
Seems like a rookie question, but I'll ask you folks before i fruitlessly burn a weekend away.

 Does anyone know where i can find documentation on how to use common operators to change a value or append string to the output of an S-Tags like [[S120:dc:giftAmount]] or [[S120:dc:donFormId]]. These would display in an Email or Autoresponder.


How to do this:

[[S120:dc:giftAmount]] * 100        

with the display being a product of giftAmount*100


or


[[S120:dc:donFormId]]  + "of CampaignB"

with the display being a string "donFormId of CampaignB"


Thanks all!
Tagged:

Comments

  • For this, you'll want to use the RPN tag S130 (see the wikipedia entry on Reverse Polish Notation for a more painfully detailed explanation).


    Your first example would look like this:


    [[S130:[[E120:dc:giftAmount]] 100 *]]


    This pushes the gift amount and the value 100 into the stack, and the * operator multiplies the previous two items in the stack.


    To add two values, then multiply the result by 100 (ex. (5 + 3) * 100), you'd write:


    [[S130:5 3 + 100 *]] => 800


    This pushes 5 and 3 into the stack and adds them (the result becomes the next value in the stack), then it pushes 100 into the stack and multiplies the previous two items in the stack.


    Complicated stuff, but super useful once you get the hang of it!


    Your second example is easier and doesn't require RPN, Just write "[[S120:dc:donFormId]] of CampaignB" without the + and it will render the string, "donFormId of CampaignB".


    Edit: Note the warning in documentation, "The S130 Tag is intended for Blackbaud internal use only; use at your own risk". Improperly formated RPN notation can do VERY strange things to your page/email, and even cripple your ability to edit content if it breaks the admin interface. The tag above for your first example should be fine though. Basically, don't experiment with RPN on live pages and use versions wisely. Also do live donation tests for autoresponders to make sure everything renders correctly. Sometimes the donation test functionality doesn't give you a completely accurate result for special stuff like this.
  • Erland Sanborn:

    For this, you'll want to use the RPN tag S130 (see the wikipedia entry on Reverse Polish Notation for a more painfully detailed explanation).


    Your first example would look like this:


    [[S130:[[E120:dc:giftAmount]] 100 *]]


    This pushes the gift amount and the value 100 into the stack, and the * operator multiplies the previous two items in the stack.


    To add two values, then multiply the result by 100 (ex. (5 + 3) * 100), you'd write:


    [[S130:5 3 + 100 *]] => 800


    This pushes 5 and 3 into the stack and adds them (the result becomes the next value in the stack), then it pushes 100 into the stack and multiplies the previous two items in the stack.


    Complicated stuff, but super useful once you get the hang of it!


    Your second example is easier and doesn't require RPN, Just write "[[S120:dc:donFormId]] of CampaignB" without the + and it will render the string, "donFormId of CampaignB".


    Edit: Note the warning in documentation, "The S130 Tag is intended for Blackbaud internal use only; use at your own risk". Improperly formated RPN notation can do VERY strange things to your page/email, and even cripple your ability to edit content if it breaks the admin interface. The tag above for your first example should be fine though. Basically, don't experiment with RPN on live pages and use versions wisely. Also do live donation tests for autoresponders to make sure everything renders correctly. Sometimes the donation test functionality doesn't give you a completely accurate result for special stuff like this.

    Erland -


    You're totally right about the warning, S130 is just a tag that allows you to do a lot, and you could cause some recursive calculations that might impact performance or cause the content of the page to render incorrectly (as any S-Tag that is malformatted might) - wanted to note one thing, on the first example, I think the E and the S need to be switched so the S120 is evaluated, then the E130.


    -John

  • John Miller:

    ...wanted to note one thing, on the first example, I think the E and the S need to be switched so the S120 is evaluated, then the E130.


    -John

     

    Good catch, you're right - E tags go on the outside!

  • Good answers and points brought up by all. Reviewed the documentation and made my widget work.  Thanks all!

     

Categories