Friday, October 18, 2013

Set Group Level Serial Number in RTC/ Visual Studio/ NAV2013 Reports

  •  Add a text box to left side of the grouping field
  • In Visual Studio Go to Report -> Report Properties->Select Code Option
  • Paste the below  code
Public Sno AS Decimal
Public Function GetSno(ByVal GroupName As String) As String
   Dim strBuilder As New System.Text.StringBuilder(GroupName )
   If GroupName .Contains("Group1") Then
      Sno = Sno +1
      Return Sno      
   Else
      Return ""
   End If
End Function   
  • Replace the Group1 by your group's Name (Go to the group Property to know the group name)
  • Click OK
  • Go To the Expressions of the newly added text box and type
  • =code.GetSno("Group1")
  • Here Replace the Group1 your group's Name (Go to the group Property to know the group name)
  • Save and run
  • Ref the screenshot below


Thanks
Marshal. J

jmarshal84@gmail.com

2 comments:

  1. Hi,

    I faced below error while saving the report after doing this.
    My Group name is 'Group1'

    ---------------------------
    Microsoft Dynamics NAV Development Environment
    ---------------------------
    Error while validating RDL content:
    There is an error on line 54 of custom code: [BC30451] 'Group1' is not declared. It may be inaccessible due to its protection level.
    ---------------------------
    OK
    ---------------------------

    Thanks
    Arvind

    ReplyDelete
  2. Hi,
    I faced below error while saving the report after doing this in Report builder 3.0.
    My group name is NoRGPHeader
    Microsoft Dynamics NAV Development Environment
    ---------------------------
    Error while validating RDL content:
    There is an error on line 38 of custom code: [BC30451] 'NoRGPHeader' is not declared. It may be inaccessible due to its protection level.
    ---------------------------
    OK
    ---------------------------

    Thanks,

    ReplyDelete