Write on Production table using script

SOLVED

Are we able to write on the Production table from the Sales Order Entry UI?

I have items that based on the S/O Entry need to be put on a Production Entry so was wondering if after they are entered in the SO and the Picking Sheet is printed, I can write this items in a new Batch and set the required fields in the Production based on lines from the S/O details.

Parents
  • 0

    You can use the BM_Production_Bus object to write production entries.  However, there isn't an event that you can attach a script to in order to catch when the picking sheet is printed.  You can however attempt to replace hide the default quick print picking sheet button and put a custom button over it in which you call the oUIObj.BT_QPPicking method and followed by your code to create the production entry where you can check the value of PickingSheetPrinted$ before you create the production entry (depending on SO Options, you may need to reread the sales order in order to get the value for PickingSheetPrinted$).

  • 0 in reply to David Speck

    Thanks David,

    Related to the above...
    I have a UDF in the lines with 3 options, I am trying to update a UDF on the header if any line has a value in the UDF.
    It seems simple but I cant get it to work.
    Any suggestions?

    I tried a pre-write/post-write/post-validate on the detail, but I am not sure how to get it to look through all the lines and IF any of them have that UDF filled out to set Header UDF to "Y"

  • 0 in reply to Hugo Rojas

    Pre-Totals, and loop through lines.

    Set oLines = oSession.AsObject(oBusObj.Lines)

    retVal = oLines.MoveFirst()

    do until oLines.EoF

    ' do stuff…

    retVal = oLines.MoveNext()

    loop ' oLines

  • 0 in reply to Hugo Rojas

    If your script is on the detail object, there should be an oHeaderObj object that you can use with the SetValue method to set the UDF on the header.  A pre-write on the detail or a post validate on the detail UDF should work to trigger this and this would work fine for flagging the header UDF but it would be a one way street.

    If the header UDF would ever need to be reversed then you are better off using a pre write event on the header and then loop through the lines until you find a line with the detail UDF set.  You could even use the detail object's GetResultSets method with a filter on your UDF and if the method returns a 1, a record was found matching your filter.

  • 0 in reply to Kevin M

    I am getting the attached error when I move to Totals

  • 0 in reply to Hugo Rojas

    Error 88 means you are either using a method that isn't valid for the object you are calling it from or you are supplying bad arguments.  Whenever you get a hard error like that, it is best to screenshot both it and what is displayed after clicking Info.

  • 0 in reply to Hugo Rojas

    This is what I have in the script

    sCustConv = ""
    sHeader = ""
    Set oLines = oSession.AsObject(oBusObj.Lines)
    
    retVal = oBusObj.GetValue("UDF_CUSTOMH$",sHeader)
    retVal = oLines.GetValue("UDF_CUST_CONV$",sCustConv)
    
    retVal = oLines.MoveFirst()
    do until oLines.EoF
    
    	If sCustConv <>"" and sHeader ="N" then
    	sHeader = "Y"
    	End if
    	retVal = oLines.MoveNext()
    
    loop oLines

  • +1 in reply to Hugo Rojas
    verified answer

    You can't do oLines.GetValue before loading a line (MoveFirst...).

Reply Children