BPM, Workflow, and Case

 View Only
  • 1.  How to calculate the data in the table

    Posted Wed July 07, 2021 09:13 AM
    I want to calculate each row of data in the table. How can I achieve this? Can you give me an example.

    ------------------------------
    ding wei
    ------------------------------


  • 2.  RE: How to calculate the data in the table

    Posted Wed July 07, 2021 09:47 AM
    Hi Ding,

    The question is not very clear, can you please elaborate the requirement?
    If you are trying to access rows of a table from UI Toolkit, this document may help you - 
    https://developer.ibm.com/recipes/tutorials/accessing-index-of-a-row-data-cell-coach-view-instances-bpm-ui-toolkit-table-control/


    ------------------------------
    Atanu Roy
    ------------------------------



  • 3.  RE: How to calculate the data in the table

    Posted Wed July 07, 2021 10:34 AM

    As shown in the figure above, a table needs to calculate:
    Total = unit price * quantity

    ------------------------------
    ding wei
    ------------------------------



  • 4.  RE: How to calculate the data in the table

    Posted Wed July 07, 2021 10:56 AM
    You need to write something similar to below snippet in the change event of unit price and quantity if you are looking to update total price on change of these two fields - 
    var index = me.ui.getIndex();
    
    page.ui.get('/table_control_id/totalPrice_control_id['+index+']').setData((page.ui.get('/table_control_id/quantity_control_id['+index+']').getData())*(page.ui.get('/table_control_id/unitPrice_control_id['+index+']').getData()));



    ------------------------------
    Atanu Roy
    ------------------------------



  • 5.  RE: How to calculate the data in the table
    Best Answer

    Posted Wed July 07, 2021 02:11 PM

    You can follow what Atanu mentioned. 

    Just so you are aware... there is an alternate shorthand that you can use as well, it suites your use-case better since you are operating within the context of the table. You are probably aware of the '@{<ControlId>}' syntax to refer to value of a field. Inside a table this syntax takes a bit different form to reference the control in the current row using '@{<ControlId>=}'. Notice the '=' after the control Id. 

    So, for simplicity, let's say your controls are named unitPrice and quantity. Then in the Total field's Events > under Value formula you can ​​enter the follow: @{unitPrice=} * @{quantity=}



    ------------------------------
    Ajay Katre | Salient Process
    ------------------------------



  • 6.  RE: How to calculate the data in the table

    Posted Wed July 07, 2021 06:08 PM
    I will do it according to your method. It has no effect. What else do I need to set?




    ------------------------------
    ding wei
    ------------------------------



  • 7.  RE: How to calculate the data in the table

    Posted Wed July 07, 2021 06:12 PM
    Oh!
    succeed!
    It needs to be calculated with the control ID.
    Thank you.


    ------------------------------
    ding wei
    ------------------------------