The Infor Communities is globally accessed system by Infor and its customers, please do not post or upload any content that could be deemed as sensitive, confidential or subject to any data regulation requirements. If you are unsure whether or not the content contains sensitive, confidential or has any data regulation requirements, please seek the advice of your internal security, legal, and compliance experts.

CSI Getting Header Value to Sum Grid Column

Hi All

 

I’m running into some issues while trying to get a header value to correctly show the summed value of a particular grid column. However, when I make a change to a value in this grid column, after I save the value is one save behind.

 

I’ve tried multiple different approaches to this – My initial thought was that it would just be a derived column and sum the values in the grid, but this didn’t work.

My next step was to try and emulate forms where this already looked to be working, namely the Customer Order Quick Entry. I noticed that the two of these forms use Triggers to Sum the header values, which I’ve also got working, but still cannot seem to get it to stay in lockstep.

Interestingly enough I see that the Purchase Order Quick Order Entry is also suffering from this issue.

I’ve tried using the following code:

   Dim bValue As Boolean

   bValue = ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex()

 

Which presents its own issues. I have it hooked up with the save completed event, but if I have the focus set inside the grid, CSI Crashes. I believe this a toolset issue as I have seen it mentioned on xtreme before.

 

I have also tried using the NotifyDependentsToRefresh function on the Primary IDO, but this too is still one refresh behind.

 

If anyone has any help or suggestions I’d be keen to hear them.

 

Cheers,

 

Jamie.

  • Hi Jamie

    I have a similar approach,Can refer to it
    My System functions operation method is
    add new grid column, keyin new value on "Machine Time(MT)" , then autosum value to Machine Time(MT) field(Before saving).

    use the Data Change events,
    Script
    --------------------------
    Dim oGridContentsCache As IWSIDOCollection
    Dim dValue As Decimal
    Dim iCount As Integer
    Dim dMTi As Decimal

    '''get the grid data
    oGridContentsCache = ThisForm.Components("grid1").IDOCollection
    dValue = 0

    '''get the field value to sum
    For iCount = 0 To oGridContentsCache.GetNumEntries - 1
    dMTi = oGridContentsCache.Item(iCount).Properties("MTi").GetValueOfDecimal(0)
    dValue = CDec(dValue + (dMTi))
    Next iCount

    '''Writeback the value to MT field, Before saving
    ThisForm.PrimaryIDOCollection.CurrentItem.Properties("MT").SetValuePlusModifyRefresh(dValue)
    ---------------------------

  • Hi There,

    Thanks fore the response. My only question in regards to this is, if for some reason the user was filtering the subgrid, for example on a specific line (I don't know why they would either, believe me), and then they update that line, the header value would sum to just that single line?

    Also, that changes the header value before the line level changes are saved does it not? If I were to refresh the form after making a change, the header value would persist, but not the changes to in the grid?

  • Hi Jamie
    Sorry. I haven't met this situation.


    「...the header value would sum to just that single line?」
    >>>if the form is Customization form, I think need add 'for loop' Script
    tell system to sum subgrid.

    I am sorry that I couldn't help

    Best Regards,

    Wayne

  • The way I have seen Infor do it follows...

    • Create temporary form variable, such as vColumnTotal
    • Create a Form Script method that adds the current line amount to the vColumnTotal variable
    • Create a Form Event Handler on StdObjectSelectCurrentCompleted to fire the Form Script method
    • Create a static component in the header row bound to the vColumnTotal variable

    When the report executes, for each line returned from the SQL procedure or IDO Extension Class, the StdObjectSelectCurrentCompleted event fires for each record in the collection. That allows you to do row by row calculations such as incrementing the value of a variable or unbound IDO Properties.

    If you want to use unbound IDO Properties, they have to exist in the list of return properties in your IDO Method configuration on your report IDO.

    Depending on how your report returns records, if you have multiple record types, you may have to add logic to only increment the amount when the record type field is a specific value. You may also have to capture the header group key value so you can clear and start the count over again between groups. That will require experimentation based on how your report data is formatted.

  • That being said...

    My preferred approach is that you handle this in your report code.

    • Create an unbound IDO Property on your report's IDO, something like GroupTotal (and column value in your SQL procedure if used)
    • In your SQL procedure or IDO Extension Class, write a section of code that loops through and updates that column based on the group key
    • Add the IDO Property to the header section in your report just like any other IDO Property and display the calculated value from your report code

    This approach makes sure your business logic is in the proper place, your report code, and provides the most consistent approach to ensure your data calculates and displays correctly. It also allows you to show the calculated total in other places in CSI where you may not be able to use the Form Script-based approach.