In Freemarker for advanced pdf/html templates, how...
# ask-stanley-ai
a
In Freemarker for advanced pdf/html templates, how can we get just the Quantity of an Inventory Detail part of an item in an iteration over record.items? Assuming item.inventorydetail contains a string with three substrings separated by spaces, for the lot number, quantity, and one other thing, then how do we get just the quantity?
c
AI generated answer (using internal Slack threads):
In Freemarker for advanced pdf/html templates, to get just the Quantity of an Inventory Detail part of an item in an iteration over record.items, you would need to split the string in
item.inventorydetail
and extract the quantity part. Assuming
item.inventorydetail
contains a string with three substrings separated by spaces, for the lot number, quantity, and one other thing, you can use the
?split
built-in function in Freemarker to split the string into a sequence (array) of strings. Here is an example of how you can do it:
Copy code
freemarker
<#assign inventoryDetails = item.inventorydetail?split(" ")>
<#assign quantity = inventoryDetails[1]>
In this example,
inventoryDetails
is an array of strings obtained by splitting
item.inventorydetail
by space.
quantity
is the second element in the array (Freemarker array indices start at 0), which should be the quantity according to your description. Please note that this assumes that the quantity is always the second substring in
item.inventorydetail
. If the order can vary, you would need a more complex logic to identify the quantity. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.859101593
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.84914875
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.834658742
Please provide your feedback on this answer.
Thank you for your feedback