Event Script Idea

SOLVED

I would like to check the detail lines within a PO to verify that all the fields have been entered.  I'd like to either run the script after the detail line has lost focus or when the user clicks the "Accept" button.  Basically I think going to place a text field(s) on the PO Lines tab and change the colors of the text to represent the data exists and is correct (green) or missing/incorrect (red).

First of all..., is this possible?  If so, what the best way of handling the events and script.

I'm decent at VB, just a newie to the Sage objects.

Thank you.

  • 0

    I don't think you can make individual lines/cells have different colors in a grid (I could be wrong).

    Typically I have created pop-up windows that appear if the script detects a possible problem.  Example:  Person does a receipt of goods and they date it for a future date (very unlikely), so I window pops up to warn them of the problem.

    If you do this,  I would highly recommend getting upgraded to 2013 or 2014.  There is a bug in the providex language in 4.4 that causes a crash if the pop-up window opens up to many times without exiting and reentering the function.

    In addition you can use custom office | user defined field and table maintenance | advanced field settings to make standard fields required/set default values/etc.  if you wish.  No script required!

  • 0 in reply to TomTarget

    > I don't think you can make individual lines/cells have different colors in a grid (I could be wrong).

    I've looked into this and no, it is not possible to change the grid color via scripting.

    I think the best option here is to create a script on the PO Purchase Order Detail, Pre-Write event. It is run for each line. If the line contains bad data, call `oScript.SetError("My error message")`. This will prevent the user from going to another line or Accepting the PO until the line is corrected.

  • 0 in reply to dlech

    Good ideas!  Thank you for your fast responses.

  • 0 in reply to DPaulTN

    OK, when I pull the individual fields, it's running well, but if I try to collect all the lines in the PO detail, I get a invalid property name error on the oBusObj.Lines object.  Just trying to make sure that I'm getting the right data...

    * Sage 100 ERP 2013

    * PO Purchase Order Detail, Pre-Write event

    * Allow Outside Assess

    itemCode = ""

    itemCodeDesc = ""

    Set oLines = oBusObj.AsObject(oBusObj.Lines)

    oLines.MoveFirst

    While Not(cBool(oLines.EOF))

      rtnVal = oLines.GetValue("ItemCode$", itemCode)

      rtnVal = oLines.GetValue("ItemCodeDesc$", itemCodeDesc)

      sAllData = sAllData & Chr(13) & itemCode & " - " & itemCodeDesc

      oLines.MoveNext

    Wend

    oScript.SetError("Pre-Write - " & sAllData)

    Ideas?

  • 0 in reply to DPaulTN

    Since the script is on the PO Purchase Order Detail object, the oBusObj variable is the line object already and it is already set to the current line. So, get rid of the loop and just do oBusObj.GetValue("ItemCode$", itemCode), etc.

  • 0 in reply to DPaulTN

    I think the best option here is NOT to create a script because this feature is built-in.  See Custom Office/User-Defined Field and Table Maintenance/Advanced Field Settings (either right-click the PO Detail table or use the 3rd icon down on the right) to access this dialog.  See the "Required" check-box that is available for all fields.

  • 0 in reply to connex

    dlech - What PO object can I use to loop thru all the detail lines?

  • 0 in reply to DPaulTN
    verified answer

    PO Purchase Order Header. If you use the pre-write event here, the script will be triggered when the user clicks the Accept button. This should work with the script you posted, I would think.

  • 0 in reply to dlech

    I agree with my esteemed colleage Connex, just make the fields all required

  • 0 in reply to dlech

    Excellent - Got it.  Thank you.