Docx from Dynamic Template

Certified Senior Developer

How to do mathematical calculations based on the received value.

Example : «${d.cost.price}» * «${f.quantity}» how to product of these two values and what is format to use to get the final result of this product.

even for addition.

Please suggest .Thanks in advance.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Try doing the calculation in appian end and pass to the node

    ="<Project>"&
    "<price>"&pv!price&"</price>"&
    "<quantity>"&pv!quantity&"</quantity>"&
    "<total>"&pv!price*pv!quantity"&"</total>"&
    "</Project>"

    Document side:

    «${doc.project.price}»
    «${doc.project.quantity}»
    «${doc.project.total}»

  • 0
    Certified Senior Developer
    in reply to gayathris0003

    Thanks for the response I have multiple values and it is CDT type 

    Item1 : cost=1,quantity=5
    Item2: cost=2,quantity=10

    How to get 1*5 
    and on next lune 2*10 value

    currently I am able to get the 

    Item Name |   Item Cost | Item Type | ItemQty | total Cost
    A                      1                 NA                5           1*5=10
    B                      10               NA                2            10*2=20

    I need to get the dynamic total cost for each row.

    Please suggest.

  • +1
    Certified Lead Developer
    in reply to lohithk0004

    You should be able to format in foreach

    <Project>
    <table labelField='Table Name'>
    <row index=1>
    <values name='pen'/>
    <values name=8/>
    <values name=10/>
    <values name=80/>
    </row>
    <row index=2>
    <values name='pencil'/>
    <values name=5/>
    <values name=10/>
    <values name=50/>
    </row>
    </Project>


    @before-row[#list doc.project.table.row as t] @after-row[/#list]
    @before-cell[#list t.values as c]
    @after-cell[/#list]

    a!localVariables(
    local!items: {
    { item: "pen", quantity: 8, cost: 10 },
    { item: "pencil", quantity: 5, cost: 10 }
    },
    concat(
    "<Project><table labelField='Table Name'>",
    joinarray(
    a!forEach(
    local!items,
    "<row index=" & fv!index & ">
    <values name='" & fv!item.item & "'/>
    <values name=" & fv!item.quantity & "/>
    <values name=" & fv!item.cost & "/>
    <values name=" & tointeger(fv!item.quantity) * tointeger(fv!item.cost) & "/>
    </row>"
    ),
    ""
    ),
    "</Project>"
    )
    )