Friday 28 August 2015



RDLC REPORTING:
·         Display fixed decimal places =FormatNumber(ROUND(SUM(Fields!Line_CBM.value),3),3)
·         DISPLAY ONLY DATE: =format(Fields!Date.Value,"dd/MM/yyyy")
·         Display data on header nav 2009 rdlc

·         Add text box in body =Fields!COMPINFO_GSTREGNO.Value and set to hidden
Then go to header add textbox =reportitems!companyGstRegNo.Value
·         If the report is going to multiple blank pages set the Top ,Left,right and bottom margin in report properties.
·         Print new line
·         Fields!customeridname.Value & vbcrlf & Fields!address1_line1.Value & vbcrlf & Fields!address1_line2.Value & vbcrlf & Fields!address1_line3.Value


Hide Dublicate values in
=iif(Fields!YourField.Value = Previous(Fields!YourField.Value), True, False)






01/01/2001 AS MONTH YEAR
=Format(CDate(Fields!A.Value), "MMMM yyyy")







SSRS - Serial number for the group column

                We were developing a report which contain a group (grouped by Product) and the group contain a detail row in it. We wanted to show Serial Number for the Products, we trying to use RowNumber function in SSRS but it didn’t come up as expected.  Finally we found the solution from Web which was written by Bilal Hani- a Microsoft Community Contributor as how to “add serial number to grouping column in SSRS Tablix”.

1. Open the report properties (right click on blank area outside the layout and click properties) or (Menu-->Report-->Report Properties)
2. Click on the code pane on the left
3. In the code window enter below script
Dim Counter as integer=0
public function getGroupCounter() as Integer
 Counter=Counter+1
 return Counter
end function
4. Go to the properties of the group (based on which group you need the group serial number)
5. Click the variables tab on the left
6. Click on Add and set Name as GroupCountValue and set the expression (in the expression window) as =Code.getGroupCounter, click ok and close the window.
7. Now in the textbox where you want to display the group number, set the expression as =Variables!GroupCountValue.Value
Make 0 as blank

Iif(quantity=0,””,quantity)



Repeat Table Header on each page:

1)in the grouping pane, click on the small triangle and select "Advanced Mode" to show static members:
1.     verify that you have the properties grid turned on (in BI Development Studio use F4, in Report Builder go to the "View" tab and select "Properties")
 
2.     select the corresponding (static) item in the row group hierarchy
 
3.     in the properties grid:
- set KeepWithGroup to After
- set RepeatOnNewPage to true for repeating headers
- set FixedData to true for keeping headers visible





=======================================================================
Shared Data50000 as Object
               
Public Function GetData(Num as Integer, Group as integer) as Object
if Group = 50000 and Cstr(Choose(2, Split(Cstr(Data50000),Chr(177))))>"" then
   Return Cstr(Choose(Num, Split(Cstr(Data50000),Chr(177))))
end if
End Function

Public Function SetData(NewData as Object,Group as integer)
If Group = 50000 and NewData <> "" Then
      Data50000 = NewData
end if
End Function


In Body:(CustDet) and set to hidden
add expression
=Fields!BilltoCustomerNo_SalesHeader.Value+ chr(177) +
Fields!BilltoName_SalesHeader.Value+ chr(177)

In Header add expression
=code.SetData(reportitems!CustDet.Value, 50000)


Header Values

=code.GetData(1, 50000)
=code.GetData(2, 50000)





(Fields!GroupingField.Value = ReportItems!LastValueOfGroup.Value)





=====================================================================
RTC
======================================================================
RTC:
Add report in Page:

Add Cardpart in Card
Create a page as Cardpart and in designer after the Container add Group type indent the fields.
Make CardPart sourcetable primary key same as Card sourcetable
InCard source table on insert trigger add below code

IF NOT ins.GET("Document Type","No.") THEN
BEGIN
ins.INIT;
ins."Document Type":="Document Type";
ins."No.":="No.";
ins.INSERT;
END;





·         Make relationship between two pages (part)
User ProviderID
http://plataan.typepad.com/microsoftdynamics/2010/04/linking-parts-on-a-page-using-the-providerid-property.html








2)


Search for Salesperson is disabled.
Add a new secondary key (salesperson code) in the table

3) Nav 2009 RTC Add field in Header or Footer

Add a field in Body and give name to text box and change it to hidden

In Header or Footer add field expression as reportitems!field.Value






For Dates, the Regional and Language Options in Windows is used to select the actual format that is used. The table below shows the Fields that will be used to build the various formats. This table, incidentally, corresponds to the Regional setting for a European country/region.
Date
Format
Example
<Closing><Day,2>-<Month,2>-<Year>
0
05-04-03
<Closing><Day,2>-<Month,2>-<Year>
1
05-04-03
<Day,2><Month,2><Year><Closing>D
2
050403D
<Closing><Year>-<Month,2>-<Day,2>
3
03-04-05
<Closing><Day>. <Month Text> <Year4>
4
5. April 2003
<Closing><Day,2><Month,2><Year>
5
050403
<Closing><Year><Month,2><Day,2>
6
030405
<Day,2><Filler Character, >. <Month Text,3> <Year4>
7
5. Apr 2003
XML format
9
2003-04-05
The following table shows how these formats will change if the Regional and Language Options is set to "United States."
US Date
Format
Example
<Closing><Month,2>/<Day,2>/<Year>
0
04/05/03
<Closing><Month,2>/<Day,2>/<Year>
1
04/05/03
<Month,2><Day,2><Year><Closing>D
2
040503D
<Closing><Year>/<Month,2>/<Day,2>
3
03/04/05
<Month Text> <Closing><Day>, <Year4>
4
April 5, 2003
<Closing><Month,2><Day,2><Year>
5
040503
<Closing><Year><Month,2><Day,2>
6
030405
<Day,2><Filler Character, >. <Month Text,3> <Year4>
7
5. Apr 2003















use dotnet class Regex.
variables:
Name DataType Subtype Length
Regex | DotNet | System.Text.RegularExpressions.Regex.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Match | DotNet |System.Text.RegularExpressions.Match.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
the code:
Match := Regex.Match('h123xxx', '\d+');  // text value = h123xxx
MESSAGE(Match.Value); // gives you 123




How to Set View Mode on Pages as Defau
...
Declare WshShell as Automation Variable for 'Windows Script Host Object Model'.WshShell
In OnOpenPage Trigger:
...
IF ISCLEAR(WshShell) THEN
CREATE(WshShell,FALSE,TRUE);
WshShell.SendKeys('^+V');//Ctrl+Shift+V

here the command for the Edit in case of
WshShell.SendKeys('^+E') //Ctrl+Shift+E
Function key
  WshShell.SendKeys('{F5}{F5}'); //Ctrl+Shift+E




Replace string function in Navision
ReplaceString(String:Text[250];FindWhat:Text[250];ReplaceWith:Text[250]) NewString:Text[250]

WHILE STRPOS(String,FindWhat) > 0 DO
  String := DELSTR(String,STRPOS(String,FindWhat)) + ReplaceWith +  COPYSTR(String,STRPOS(String,FindWhat) + STRLEN(FindWhat));
NewString := String;


Subform setselectionfilter:
Create a variable PurchaseLine
CurrPage . SETSELECTIONFILTER ( PurchaseLine ); 
// you can also test purposes here MESSAGE (FORMAT (PurchaseLine.COUNT)) settle. 
IF PurchaseLine . FindSet THEN BEGIN 
  REPEAT 
    
// whatever you intends test with the selected records 
  UNTIL PurchaseLine . NEXT  =  0 ; 
END ;

========================================================================
FILTER RECORDS ON PAGE

OnFindRecord(Which : Text[1024]) : Boolean
exit(find(which) and ShowThisRecord);

OnNextRecord(Steps : Integer) : Integer
create a local variable
Local Variables
Name         | DataType
ResultSteps  | Integer
then add the following code

REPEAT
  ResultSteps := NEXT(Steps);
UNTIL (ResultSteps = 0) OR (ShowThisRecord);
EXIT(ResultSteps);

ShowThisRecord() : Boolean
g_recPH2.GET("Document Type","Document No.")
 IF g_recPH2."Assigned User ID" = USERID THEN
EXIT(TRUE)

===============================================================================



* NAV 2009 Run Report From RUN
Dynamicsnav:////runreport?report=50000

*Make relationship between two pages (part)
User ProviderID
http://plataan.typepad.com/microsoftdynamics/2010/04/linking-parts-on-a-page-using-the-providerid-property.html


RTC:
Attach report in Page:
g_recSH.GET("Document Type","No.");
CurrPage.SETSELECTIONFILTER(g_recSH);
REPORT.RUNMODAL(50000,TRUE,FALSE,g_recSH);

Or

CLEAR(g_recSIH);
g_recSIH.SETRECFILTER;

REPORT.RUNMODAL(REPORT::"Invoice",TRUE,FALSE,g_recSIH);


Add Cardpart in Card
Create a page as Cardpart and in designer after the Container add Group type indent the fields.
Make CardPart sourcetable primary key same as Card sourcetable
InCard source table on insert trigger add below code

IF NOT ins.GET("Document Type","No.") THEN
BEGIN
ins.INIT;
ins."Document Type":="Document Type";
ins."No.":="No.";
ins.INSERT;
END;


Search for Salesperson is disabled.
Add a new secondary key (salesperson code) in the table




use dotnet class Regex.
variables:
Name DataType Subtype Length
Regex | DotNet | System.Text.RegularExpressions.Regex.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Match | DotNet |System.Text.RegularExpressions.Match.'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
the code:
Match := Regex.Match('h123xxx', '\d+');  // text value = h123xxx
MESSAGE(Match.Value); // gives you 123




How to Set View Mode on Pages as Default
...
Declare WshShell as Automation Variable for 'Windows Script Host Object Model'.WshShell
In OnOpenPage Trigger:
...
IF ISCLEAR(WshShell) THEN
CREATE(WshShell,FALSE,TRUE);
WshShell.SendKeys('^+V');//Ctrl+Shift+V

here the command for the Edit in case of
WshShell.SendKeys('^+E') //Ctrl+Shift+E
Function key
  WshShell.SendKeys('{F5}{F5}'); //Ctrl+Shift+E









Replace string function in Navision
ReplaceString(String:Text[250];FindWhat:Text[250];ReplaceWith:Text[250]) NewString:Text[250]

WHILE STRPOS(String,FindWhat) > 0 DO
  String := DELSTR(String,STRPOS(String,FindWhat)) + ReplaceWith +  COPYSTR(String,STRPOS(String,FindWhat) + STRLEN(FindWhat));
NewString := String;


Subform setselectionfilter:
Create a variable PurchaseLine
CurrPage SETSELECTIONFILTER PurchaseLine );// you can also test purposes here MESSAGE (FORMAT (PurchaseLine.COUNT)) settle.IF PurchaseLine FindSet THEN BEGIN
  REPEAT
    
// whatever you intends test with the selected records  UNTIL PurchaseLine NEXT   0 ;END ;


FILTER RECORDS ON PAGE

OnFindRecord(Which : Text[1024]) : Boolean
exit(find(which) and ShowThisRecord);

OnNextRecord(Steps : Integer) : Integer
create a local variable
Local Variables
Name         | DataType
ResultSteps  | Integer
then add the following code

REPEAT
  ResultSteps := NEXT(Steps);
UNTIL (ResultSteps = 0) OR (ShowThisRecord);
EXIT(ResultSteps);

ShowThisRecord() : Boolean
g_recPH2.GET("Document Type","Document No.")
 IF g_recPH2."Assigned User ID" = USERID THEN
EXIT(TRUE)



12 comments:

  1. Lookup record:


    pg_SalesInvList.SETTABLEVIEW(recSalesHdr);
    pg_SalesInvList.EDITABLE(FALSE);
    pg_SalesInvList.LOOKUPMODE := TRUE;
    IF pg_SalesInvList.RUNMODAL IN [ACTION::OK,ACTION::LookupOK] THEN BEGIN
    pg_SalesInvList.GETRECORD(recSalesHdr);
    "Tax Invoice No." := recSalesHdr."Posting No.";
    END;

    ReplyDelete
  2. Print Report of Different Data Item:

    CurrPage.SETSELECTIONFILTER(Rec);
    rsSalesHdr.RESET;
    rsSalesHdr.SETRANGE("Whse. Source No.", "No.");
    IF rsSalesHdr.FINDFIRST THEN;

    REPORT.RUNMODAL(REPORT::"Delivery Order",TRUE,FALSE,rsSalesHdr);

    ReplyDelete
  3. Print Report of Different Data Item:

    CurrPage.SETSELECTIONFILTER(Rec);
    rsSalesHdr.RESET;
    rsSalesHdr.SETRANGE("Whse. Source No.", "No.");
    IF rsSalesHdr.FINDFIRST THEN;

    REPORT.RUNMODAL(REPORT::"Delivery Order",TRUE,FALSE,rsSalesHdr);

    ReplyDelete
  4. Find Start Date of the month / Last date of the month
    datFirstDayofMonth := DMY2DATE(1,DATE2DMY(TODAY,2),DATE2DMY(TODAY,3));
    datLastDayofMonth := CALCDATE('<1M>',datFirstDayofMonth)-1;

    ReplyDelete
  5. Get Invoice No from shipment

    g_fnGetFromSalesInvoiceLine()
    g_recSSL.RESET;
    g_recSSL.SETRANGE("Document No.","No.");
    g_recSSL.SETRANGE(Type,g_recSSL.Type::Item);
    IF g_recSSL.FINDFIRST THEN
    REPEAT
    CLEAR(TempSalesInvLine);
    g_recSSL.GetSalesInvLines(TempSalesInvLine);
    IF TempSalesInvLine.FINDFIRST THEN
    cdeDocNO := TempSalesInvLine."Document No.";
    REPEAT
    IF TempSalesInvLine."Document No." <> cdeDocNO THEN
    ERROR('Shipment has multiple Invoices.Cannot Print the Report');
    UNTIL TempSalesInvLine.NEXT =0 ;
    UNTIL g_recSSL.NEXT = 0;
    g_recSIH.GET(TempSalesInvLine."Document No.");

    ReplyDelete
  6. https://community.dynamics.com/nav/f/34/t/180552


    https://community.dynamics.com/nav/b/navteam/archive/2013/11/14/microsoft-dynamics-nav-2013-r2-pllp-toolkit-released

    https://msdn.microsoft.com/en-us/library/ee414196(v=nav.90).aspx

    ReplyDelete
  7. Get Previous record

    SalesLine2.COPY(Rec);
    IF SalesLine2.NEXT(-1) = 0 THEN
    MESSAGE('NC')
    ELSE BEGIN
    SalesLine2.RESET;
    SalesLine2.ASCENDING(FALSE);
    SalesLine2.SETRANGE("Document Type","Document Type");
    SalesLine2.SETRANGE("Document No.","Document No.");
    SalesLine2.SETFILTER("Line No.",'<%1',"Line No.");
    IF SalesLine2.FINDFIRST THEN REPEAT
    IF (blnFound = FALSE) AND (SalesLine2.Type = SalesLine2.Type::" ") AND (SalesLine2."No." = '') THEN BEGIN
    MESSAGE(SalesLine2.Description);
    blnFound := TRUE;
    END;
    UNTIL SalesLine2.NEXT = 0;
    END;

    ReplyDelete
  8. Setselection filter on form/page
    TempItem.DELETEALL;

    CurrPage.SETSELECTIONFILTER(Item);
    IF Item.FINDSET THEN
    REPEAT
    TempItem := Item;
    TempItem.INSERT;
    UNTIL Item.NEXT = 0;

    //Test our selection worked
    TempItem.RESET;
    IF TempItem.FINDSET THEN
    REPEAT
    MESSAGE(TempItem."No.");
    UNTIL TempItem.NEXT = 0;

    IF ItemList.RUNMODAL= ACTION::LookupOK THEN
    ItemList.GetSelectedItems(TempItem);

    ReplyDelete
  9. Example
    Progress indicator based on Item DataItem
    Create a report with Item as the dataitem.
    Put the code below in the prescribed triggers.
    Define the variables, Run the report
    The TotalCount will adjust per the filters you enter on the report so the
    progression bar is always on time.

    Variables
    Name DataType
    Window Dialog
    TotalCount Integer
    Counter Integer

    Item - OnPreDataItem()
    Window.OPEN('Processing: @1@@@@@@@@@@@@@@@');
    TotalCount := COUNT;
    Item - OnAfterGetRecord()
    Counter := Counter + 1;
    Window.UPDATE(1,ROUND(Counter / TotalCount * 10000, 1));

    Item - OnPostDataItem()
    Window.CLOSE;

    How-to use Dialog Box with Progress Indicator
    Try using a dialog box, but instead of using (ex. '#1######') you use
    (ex. @1@@@@@@@@@@@@@). The "@" sign signifies that you want to use
    progress bar indicator.

    Source http://groups.yahoo.com/group/Navision-Knowledge-Village/

    ReplyDelete
  10. Name ConstValue
    Text032 Creating general journal lines...\\
    Text033 Employee Code #1##########\
    Text034 Status @2@@@@@@@@@@@@@@@@@@@@



    Employee Master - OnPreDataItem()
    Window.OPEN(Text032 + Text033 +Text034);
    TotalCount := COUNT;

    Employee Master - OnAfterGetRecord()
    Window.UPDATE(1,EmpID);
    Counter := Counter + 1;
    Window.UPDATE(2,ROUND(Counter / TotalCount * 10000, 1));

    Employee Master - OnPostDataItem()
    Window.CLOSE;

    ReplyDelete
  11. https://www.dynamics101.com/inventory-reconciliation-part-ii-understanding-inventory-transactions/

    ReplyDelete
  12. SetSelection:

    {
    Route.RESET;
    RouteList.SETTABLEVIEW(Route);
    RouteList.EDITABLE(FALSE);
    RouteList.LOOKUPMODE := TRUE;
    IF RouteList.RUNMODAL IN [ACTION::OK,ACTION::LookupOK] THEN BEGIN
    RouteList.g_fnSetSelection(Route);
    IF Route.FINDSET THEN REPEAT
    IF g_txtRouteFilter = '' THEN
    g_txtRouteFilter := Route."Route Code"
    ELSE
    g_txtRouteFilter += '|' + Route."Route Code";
    UNTIL
    Route.NEXT = 0;
    END;
    }

    ReplyDelete