<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Xpath function for line items total in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/xpath-function-for-line-items-total/m-p/318264#M5265</link>
    <description>&lt;P&gt;Hi guys, I created a document type Purchase Order with the possibility of adding several  items. Each item has an item description, a quantity, price and total item value (to be caclulated). Knowing that the user has the possibility of adding more items. Hence in a Purchase Order type, I have fields that are string and others that are complex. To get each line item total calculed I used the following automation script. I can get the purchase order total calculated but not the line totals. Thanks in advance for your help:
function run(input, params) {
var items = input.getProperty("PurchaseOrder:items");
var total;
var totalS=0;&lt;/P&gt;
&lt;P&gt;for (var i=0; i&amp;lt;items.length; i++) {
total=0;
total=quantity[i].price*items[i];&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;  items[i].total=total;
totalS=totalS+items[i].total;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;}
Document.SetProperty (input, {
'xpath':"PurchaseOrder:total",
'save':false,
'value':totalS&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;                    });
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;return input ;&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2017 19:19:17 GMT</pubDate>
    <dc:creator>Han_Adam</dc:creator>
    <dc:date>2017-05-22T19:19:17Z</dc:date>
    <item>
      <title>Xpath function for line items total</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/xpath-function-for-line-items-total/m-p/318264#M5265</link>
      <description>&lt;P&gt;Hi guys, I created a document type Purchase Order with the possibility of adding several  items. Each item has an item description, a quantity, price and total item value (to be caclulated). Knowing that the user has the possibility of adding more items. Hence in a Purchase Order type, I have fields that are string and others that are complex. To get each line item total calculed I used the following automation script. I can get the purchase order total calculated but not the line totals. Thanks in advance for your help:
function run(input, params) {
var items = input.getProperty("PurchaseOrder:items");
var total;
var totalS=0;&lt;/P&gt;
&lt;P&gt;for (var i=0; i&amp;lt;items.length; i++) {
total=0;
total=quantity[i].price*items[i];&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;  items[i].total=total;
totalS=totalS+items[i].total;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;}
Document.SetProperty (input, {
'xpath':"PurchaseOrder:total",
'save':false,
'value':totalS&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;                    });
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;return input ;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2017 19:19:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/xpath-function-for-line-items-total/m-p/318264#M5265</guid>
      <dc:creator>Han_Adam</dc:creator>
      <dc:date>2017-05-22T19:19:17Z</dc:date>
    </item>
  </channel>
</rss>

