วันพุธที่ 20 ตุลาคม พ.ศ. 2553

การเขียน beanshell เพื่อคำนวนค่าใน row-actions

ใน OFBiz เราสามารถคำนวนค่าใดๆ ในแต่ละแถวของการแสดงผลของ form ได้ โดยใช้คำสั่ง beanshell script ใน action หรือ row-actions ของ form ดังนี้

<row-actions>
            <set field="estimatedTotalMilliSeconds" value="${bsh:estimatedMilliSeconds * quantity}" type="BigDecimal"/>
</row-actions>

จากโค้ด ได้ทำการคำนวน โดยการนำค่าของ estimatedMilliSeconds มาทำการคูณกับ quantity แล้วเก็บไว้ในตัวแปร estimatedTotalMilliSeconds
โดยหากใช้คำสั่ง <row-actions> นั่นจะหมายถึง มีการคำนวนค่านี้ในทุกแถวที่มีการ process ค่านี้ออกมา

ไม่มีความคิดเห็น:

แสดงความคิดเห็น