Options

Count in FlowField - display the results in a Group Footer

ccernatccernat Member Posts: 12
Hello all!

Im new here and also to Navision scene. My problem is the following:

I have created a field in a table, type FlowField with the CalcFormula = Count("Domestic Declaration Line" WHERE (Type=CONST(Purchase),Posting Date=FILTER(01/11/12..30/11/12),VAT Registration No.=FIELD(VAT Registration No.)))

Now, this field in the Table, named "Count Purchase" has to be displayed in a report wich create some totals from this table based on some filters, etc.

I assigned a global variable cntEntries to this field from the table and I have put it in the Group Footer section of the report.

In the PreSection of the Group Footer i've put: cntEntries := DomesticDeclarationLine."Count Purchase";

Where DomesticDeclarationLine is my table and Count Purchase is my field created as FlowField wich does some counting based on the above CalcFormula.


My problem is it displays 0 all the time, although if I open the form related to that table, the counting is correct.


Where is could be the problem?



Thanks a million for any help!

Comments

  • Options
    geordiegeordie Member Posts: 655
    Before assigning the value of the FlowField, you have to use CALCFIELDS statement:
    DomesticDeclarationLine.CALCFIELDS("Count Purchase");
    cntEntries := DomesticDeclarationLine."Count Purchase";
    
    And also you should move in OnAfterGetRecord trigger: if you need to perfom any totalization on this field, you can set it in TotalFields property of the DataItem and use directly "Count Purchase" in GroupFooter sections.
  • Options
    ccernatccernat Member Posts: 12
    Thanks alot for the reply!!

    It isnt working, it outputs the same result for for all the entries.

    I want to better explain the situation:

    I have a GroupFooter in a report with has a GroupTotals propery by a unique VAT number and has TotalFields for the Amount corresponding to each VAT number. All this date comes from Domestic DeclarationLine table in wich I have multiple Purchase type entries for each VAT number, thus the necessity of a totalling. I needed to COUNT those Purchase entries based on certain date filters and VAT Number. And it does well at the table level. But when I put it in the Group Footer section of the report, it just outputs wrong numbers....even though I've put CALCFIELDS where you directed me to put em.

    I will attach some print screen maybe it will help me to express better.
  • Options
    ccernatccernat Member Posts: 12
    I will attach one more to see where i need this field cntEntries to appear.
  • Options
    vijay_gvijay_g Member Posts: 884
    I don't see the CREATETOTAL() in the predataitem(). I might be wrong in understating but if you want to show the total of any field in group by help of any variable then you should use this function to get the desired output.
  • Options
    william_marcelinuswilliam_marcelinus Member Posts: 34
    I think your data items not link correctly to purchase header. check with message in purchase header onAftergetrecord if it did have value or not.
  • Options
    k0n4nk0n4n Member Posts: 25
    Hello,

    In the property Code of the report you need to write:
    Shared Data1 as Object
    Shared Data2 as Object
    Shared Data3 as Object
    Shared Data4 as Object
    
    Public Function GetData(Num as Integer, Group as integer) as Object
    if Group = 1 then
       Return Cstr(Choose(Num, Split(Cstr(Data1),Chr(177))))
    End If
    End Function
    
    Public Function SetData(NewData as Object,Group as integer)
      If Group = 1 and NewData > "" Then
          Data1 = NewData
      End If
      Return True
    End Function
    

    Then you need to create a textbox in report body, with this code in the hidden property:
    Code.SetData(Cstr(Fields!1.Value), 1)
    

    If you want tu write more fields in footer:
    Code.SetData(Cstr(Fields!1.Value) +Chr(177)+Cstr(Fields!2.Value) +Chr(177), 1)
    

    Then in the textbox where do you want display the field you need to write in the value expresion
    Code.GetData(n,1)
    
    if you want to display more fields you need count the position of field in the Code.SetData


    I hope that works

    Regads
  • Options
    k0n4nk0n4n Member Posts: 25
    Sorry, My last post is for NAV2013 or NAV2013R2
Sign In or Register to comment.