I need to have script execute on the selection of a line in a grid (SO Lines specifically).

SOLVED

Need to have a script run as soon as a user selects a field on a line in a grid.  I'm not sure which event can control this or how.  

Any ideas?

[I posted a similar question in the Customization section.  I wasn't sure how to make it show up in this section too, so I've replicated it here.  Sorry for the redundancy.  If there is a way to avoid this, I'm listening...]    

  • 0
    There isn't an "on enter" event. What about post-validate on another field?
  • 0
    Could you describe your objective? You can trigger an event when a new line is created ("Set Default Values"), but not on the selection of a row.
  • 0 in reply to connex
    I controlled data entry previously by having users to click a button script that reads the data, evaluates what is required, then either proceeds to open a panel for data entry, or a message saying editing is not allowed. This was in place in version 4.30

    I now (version 2015) want to improve the process so that when the user selects a line, the same evaluation is done. I just need to have a way to trigger the script that evaluates things.
  • 0 in reply to brc
    What exactly do you mean by "reads the data"? Do you mean data from the line itself, or from the sales order header? Information from the customer? When you say "evaluates what is required", what do you mean by that? What is required in what manner? Required for the quantity ordered field? Required for a UDF? When you say "open a panel for data entry" what panel are you referring to? The grid entry in S/O lines? I don't completely understand what you are saying; I'm wondering if you can post a screen shot or explain a little more.
  • 0 in reply to Dawn Anastasi
    The way it works in 4.30, the user selects a line in a grid. Then the user clicks the Button Script.

    The script associated with the button reads in various SO Line details and Line UDF values.

    Without going into too much ancillary details (because there is a lot), there is a UDF that monitors the status of a line. If the status is such that the user can adjust values in line udfs, then the user can proceed (a panel opens up and has line UDF fields that can be edited), else the warning message appears and moves the focus off the line entry to a last line in the grid.

    Hope that more clear.
    Brian
  • 0 in reply to brc
    If you're processing after entering some data on a line (item, some UDFs) then just have the "post validate" event on the last UDF they would enter data for.
  • 0 in reply to brc
    If your description above is complete, then you could use a Post Validate event script on the quantity shipped field (every line must have that field entered) that examines the line's status UDF and if necessary open a panel with the UDF's so they can be altered.
  • 0 in reply to connex
    I want the script to fire as soon as the user lands on the grid line, not after they enter a quantity. I want to validate that they can edit the line at all. Also, the user might not be changing the quantity, just other UDF values. The only way I can see this working is to have a script attached to each Column with Pre-validate that would be in the grid which would do the checking. Cumbersome but perhaps doable.
  • 0 in reply to brc

    It was a suggestion for an alternate method to implement your enhancement, that if your conditions were not satisfied - you could reject the modification (leaving your record in tact).

  • 0 in reply to connex
    verified answer

    et al,

    Sorry for being late to this party.

    I think what may work for you is to put a script attached to the Post-Read event of the detail table. Each time a user selects a different row it will read the table for the data and thus the Post-Read event will fire. Keep in mind this is true for NEW rows too. So when the user chooses the blank row at the end of the data entry it also does a Post-Read for the creation of a NEW record. Depending on what you want to do you can use oBusObj.EditState to determine whether you are reading a new row or an existing row.

    oBusObj.Editstate = 0 (No record to be editted)
    oBusObj.Editstate = 1 (Modifying an existing record)
    oBusObj.Editstate = 2 (Creating a new record)

    Hopefully this helps
    Elliott