Add calculated field to Sales Order entry Line Item

SOLVED

We enter our orders in each qty, but would like to show a field with the calculation of case qty.  I don't need this value stored, just would like to see it on the screen.  I have added my UDF that contains the case qty to the lines tab.  I don't see how to add a field/column that can be calculated.  Is it possible to do this?

  • 0

    It is not easy to get a read only calculated value, i think i have a way to do this floating around here using some advanced scripting techniques though.

  • 0

    You would have a script attached to the quantity field and when an number is entered it multiplies it by the case qty UDF and displays in another UDF. Simple really.

  • 0 in reply to BigLouie

    Yes, my answer was for the requirement that the value would not be stored (read only). Two ways to handle this but it is easier to implement if you store the calculated value in the UDF as per BigLouie's answer.

  • 0

    Yeah I am not opposed to it being stored value if it makes it easier. If you have some similar script code that I could start with that would be great.  I have done a little bit with scripting so I may be able to get it working I think a question I would end up having is if it should be pre, post or whatever those options are to apply the script.

  • +1 in reply to gseales
    verified answer

    You need two UDFs added to SO_SalesOrderDetail.

    The first UDF can source the case quantity from CI_Item if you have it there and/or it can be free form. Make sure it is numeric or you will have to convert its value in your script.

    The second UDF can be locked and will hold the calculated value.

    The script should be assigned to the post-validate event of the QuantityOrdered column and you may need it on the post-validate event of the first UDF as well so if the user changes either column, the calculated value will be updated. You may or may not also need it on the post-read event of SO_SalesOrderDetail if you have already had the first UDF and it has been populated, this will make sure that when a line is selected, the calculated value will be updated, this will however trigger the prompt to save changes to the order if the calculated value is updated.

    Regarding the script contents, you just need to use the GetValue method on the quantityordered and first UDF columns, then use SetValue on the second UDF with the calculated value. It also wouldn't hurt to check that oBusObj.SecurityAccess is greater than 1