How do I modify the purchase order template, so I can call the correct Vendor ID?

dkoleanb21dkoleanb21 Member Posts: 18 ✭

The way the purchase order template is written right now, it calls the default Vendor ID for purchase orders from any Vendor rather than the Vendor ID that is associated with that Vendor.

I'm trying to modify the purchase order template, so it checks the {{Order.vendorID}} attribute to see what the Vendor's ID is and then iterates through the ItemVendorNum array until it locates the nth object in the array that contains the matching vendor ID. Then, I would call the Vendor ID.

First, I just wanted to make sure I could access the correct object in the ItemVendorNum array, but for some reason I can't call the 2nd object. I feel like I should be able to access the 2nd object with the following code:


Here's what I'm trying to call from:





I'm no coding expert, so if anyone is able to help explain why I can't access the 2nd object, that would be great.

Thank you!




  • bdstrohsbdstrohs Member Posts: 8


    {{OrderLine.Item.ItemVendorNums.ItemVendorNum.1.value}} should get you the second object.

    Here's the code I came up with that properly cycles through the array, but the conditional statement always returns true even when the vendorIDs match. If you get it to work, please share. The proper vendor code is a necessity for us too.

    {% for num in OrderLine.Item.ItemVendorNums.ItemVendorNum %}

    {% if num.vendorID == Order.Vendor.vendorID %}


    {% endif %}

    {% endfor %}

  • dkoleanb21dkoleanb21 Member Posts: 18 ✭


    I finally figured it out. Your code is perfect, but there's a type difference that prevents the comparison from working properly.

    I couldn't figure out how to convert them to ints, but I ended up converting the vendorIDs to money and then perform the comparison, and your code works like a charm.

    {% for num in OrderLine.Item.ItemVendorNums.ItemVendorNum %}

    {% if num.vendorID|money == Order.Vendor.vendorID|money %}


    {% endif %}

    {% endfor %}

Sign In or Register to comment.