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

dkoleanb21dkoleanb21 Member Posts: 12

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:

{{OrderLine.Item.ItemVendorNums.ItemVendorNum[1].value}}


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

"ItemVendorNums":{"ItemVendorNum":[

{"itemVendorNumID":"631","value":"6046","timeStamp":"2021-03-17T03:16:28+00:00","cost":"0.00","itemID":"1052","catalogVendorItemID":"0","vendorID":"21"},

{"itemVendorNumID":"4312","value":"16501109","timeStamp":"2021-05-11T01:56:44+00:00","cost":"0.00","itemID":"1052","catalogVendorItemID":"0","vendorID":"44"}

]},


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!

Desmond

CameraMall

1 comment

  • bdstrohsbdstrohs Member Posts: 7

    @dkoleanb21

    {{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 %}

    {{num.value}}

    {% endif %}

    {% endfor %}

Sign In or Register to comment.