Page 1 of 1

nVelocity - Convert Shipment Number to Letter

Posted: Mon Aug 17, 2009 10:47 am
by ZLA
Is it possible to convert the shipment number to a letter? For example if we have shipment numbers 1, 2, ... can we display that as A, B, ... using nVelocity in the vendor notification email template?

Thanks in advance.

Re: nVelocity - Convert Shipment Number to Letter

Posted: Mon Aug 17, 2009 3:55 pm
by Logan Rhodehamel
With nVelocity, usually the answer is yes. Toward the top find little code like:

Code: Select all

#set ($shipNo = 1)
Then change it to this:

Code: Select all

#set ($shipLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ")	
#set ($shipNo = 0)
Then a few lines down it shows the shipment label (like 1 of 2). Change that to this:

Code: Select all

<strong><u>Shipment ${shipLetters.Substring($shipNo, 1)}</u></strong>
So basically, I created a string variable then accessed the substring property. Warning, if you get more than 26 shipments in an order it will break.

Re: nVelocity - Convert Shipment Number to Letter

Posted: Tue Aug 18, 2009 8:37 am
by ZLA
Thank you Logan. I couldn't find a list of nVelocity String functions so I didn't know what I had to work with. Given substring, yours is the obvious solution. Thanks again.

Re: nVelocity - Convert Shipment Number to Letter

Posted: Tue Aug 18, 2009 8:49 am
by Logan Rhodehamel
In some ways it helps to think of nVelocity as .NET compiler - you get the full range of .NET methods and properties for any variable. Sometimes the trick is figuring out how to get the variable. Since I know we can create a string variable using the nVelocity set command, that would give you access to all of these:

http://msdn.microsoft.com/en-us/library ... mbers.aspx

Re: nVelocity - Convert Shipment Number to Letter

Posted: Tue Aug 18, 2009 1:20 pm
by ZLA
Thanks.