Sage 100

 View Only
Expand all | Collapse all

Refresh Grid Lines After deleting a line

  • 1.  Refresh Grid Lines After deleting a line

    Posted 10-24-2019 18:55
    Hopefully this is an easy one.  I have customer needing to block certain product lines from being included on PO lines. So what we have so far is a Pre-Validate SetError on Qty Ordered field.  It works fine, but leave the line intact with an ordered quantity of 0, which flows through to history.  I have seen some warnings against using the oScript.Delete() on the business object itself, but I would prefer to delete the line and refresh the grid by invoking a "Refresh Grid" button script, rather than using the Table Pre-Write to SetError on.  But I'm wondering if there are some catch 22's with this.  The button script I created on DMAIN refreshes the grid fine when I press it manually.  But it does not seem to be invoking from the Pre-Validate script.  Is this possible to do from a pre-validate event?  Or could it be because I'm trying to invoke a button after deleting the line I'm actually in?

    Thanks in advance!

    ------------------------------
    Rob Neal
    ServiceWorld Business Solutions
    ------------------------------


  • 2.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 09:23
    Doesn't Pre-Validate on the ItemCode make more sense?  Then you don't need to clean up lines.
    If you script within grids, you have to be careful that the lines business object and the UI don't become out of sync.
    PreTotals for a loop cleanup is easier... no display issues.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 3.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 11:57
    Good point, Kevin. I failed to mention that I started with Pre-Validate on the ItemCode, but it didn't recognize any of the GetValue's.  Strangely, the results of the GetValues would show up the next line I attempted to enter.  I'm assuming it's because of the "pre."  And you can only do SetError's on Pre- events, correct?  Thanks for the PreTotals loop idea.  I had considered that, but right now, the script is leaving the line in a strange state that makes the user think they can still enter data on the line.  It looks correct...even lets them choose a different item number and displays quantity, price and extended price correctly, but when you click Totals (or any other tab) and return to Lines, the line is gone.  That was my motivation for cleaning up the line and refreshing the grid immediately.  But ideally, I'd rather trigger off the ItemCode for sure.

    ------------------------------
    Rob Neal
    ServiceWorld Business Solutions
    ------------------------------



  • 4.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:08
    Pre event is required for a SetError. 
    For any column trigger, the "value" is what the user entered... and if you need data not available using GetValue within oBusObj, take the ItemCode "value" and open a new object to do your look-ups.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 5.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:15


    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 6.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:34
    I didn't think the "value" variable would come into play because I'm really needing to pull the value of the ProductLine field.  The "value" variable does work fine.  Sorry if I didn't make it clear that I'm trying to prevent certain product lines, which is probably why I'm getting the delay in the data.  Hopefully this makes sense.

    ------------------------------
    Rob Neal
    ServiceWorld Business Solutions
    ------------------------------



  • 7.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:39
    If GetChildHandle doesn't work to pull up the ItemCode record (where you can check the PL), open a new object and use the Value to find the correct entry.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 8.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:43
    In that case, @Kevin Moyes, I'll likely just open a new connection to CI_Item via the "value" ​variable like you mentioned.  Thanks.

    ------------------------------
    Rob Neal
    ServiceWorld Business Solutions
    ------------------------------



  • 9.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:53
    GetChildHandle is more efficient, if it works, with no external permissions required.  Opening the service object manually requires permission to Item Inquiry.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 10.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 13:23
    Thanks @Kevin Moyes and @Alnoor Cassim for the tips.  All is well now that I used GetChildHandle.  I appreciate the help!​​

    ------------------------------
    Rob Neal
    ServiceWorld Business Solutions
    ------------------------------



  • 11.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 11:04
    Edited by Alnoor Cassim 10-25-2019 11:24
    Rob - Calling a button (which you correctly placed in DMain(w)) for grid refresh will make the most sense on the Detail Table Post-Write or Post-Delete. The concern with oBusObj.Delete() (assuming oBusObj here is pointing to the Lines) is it will not retain history if you have Retain Deleted Lines for S/O Order History enabled. The .DeleteLine(EditKey) variation does retain the deleted line in history.

    ------------------------------
    Alnoor Cassim

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------



  • 12.  RE: Refresh Grid Lines After deleting a line

    Posted 10-25-2019 12:01
    Thanks Alnoor...I thought about a table event instead of a column, and might have to do that, but customer complained that they didn't want the users going to all the effort of entering the entire line item before realizing it's being deleted.  Same story as what I mentioned to @Kevin Moyes, that the script in its current state is leaving the line in what appears to be an editable state.  I'd love to trigger this off the ItemCode (pre-validate), but I'm running into the scenario that the GetValues aren't populating the variables until after the line is written.  Is that by design?  I'm realizing I've probably never done a pre-val script on a line key before this.   Thanks everyone.​

    ------------------------------
    Rob Neal
    ServiceWorld Business Solutions
    ------------------------------