Wednesday, 9 July 2014

How to Use Chart Components in NAV 2013

Navision had given a facility to use Chart object. Where user can drilled down and navigate till the document level.We can take one example where user can see the overall profit in the graphical format.

For getting profit we need to create 2 Analysis Views which are updatable.
  •           Revenue
  •           Expenses
Note : User must select the proper set of accounts for Revenue and Expenses

Following are the steps to create a Chart

1. Create a Page(Profit Chart) which includes Business Chart Buffer as a source table



















2. Select the Field Business Chart


3.  Create a separate code unit for Updating and Calling the Chart

4. Following Functions Needs to be created in Code Unit
    a.  UpdateDataPL – Updating the data for Actual Revenue/Expense Profit


In the above example Initialize, SetAxis, AddColumn, SetValueByIndex are the functions of Business Chart Buffer Table. A separate Table(In This Case Job Profitablity Setup Table) and Field is used to calculate The Total Revenue and Total Expense as a flow field which is pointed to Revenue & Expense Analysis View entries.

    b.  DrillDownRevenue – Use this function for Drilling down to The Analysis View Entry Revenue



    c.  DrillDownExpense – Use this function for Drilling down to The Analysis View Entry Expense



5. All the above functions needs to call from Profit Chart Page.
6. Create a separate Function Called UpdateChart on Page. This function needs to call on OnfindRecord Event on Page.



7. We need to write a code on Datapointclicked event of the page for drilled down to the transaction level

8. Now you can attach this page to role center. Before calling the page please make sure there is a record for user id must be available in the setup table. If the user is not available then please create a user. ( In the above scenario Job Profitability Setup table which has been used which is a customized table. Useid,Revenue(FlowField),Expenses(Flowfield) are the three required fields has been taken from that table. Revenue field consist sum amount from the Analysis Entry Table for the Analysis View "Revenue". Expense field consist sum amount from the Analysis Entry Table for the Analysis View "Expenses".)





Wednesday, 2 July 2014

Prevent Negative Inventory


Many years various clients asking for the functionality of preventing Negative entry which has been provided by Microsoft in Nav 2013 R2. This provision has been given by Microsoft in Inventory Setup.


If the Prevent Negative Inventory setup is marked at Inventory Setup then, Inventory has been checked for all Items.
If the Prevent Negative Inventory setup is not marked at Inventory Setup then, In Item Master there is field called Prevent Negative Inventory needs to be checked. In this scenario, The Inventory will get checked for those Items which are marked with Prevent Negative Inventory


In Standard Navision, I observed that This Functionality is only worked for Sales. But when I tried to post with Item journal and entry type is “Negative Adjt.”. The entry get posted with negative Inventory. To prevent user from posting negative Inventory, I have done a small change in the function written in Item Ledger Entry Table Called “VerifyOnInventory”

Old Code
IF NOT Open THEN
  EXIT;
IF Quantity >= 0 THEN
  EXIT;
CASE "Entry Type" OF
  "Entry Type"::"Negative Adjmt.","Entry Type"::Consumption,"Entry Type"::"Assembly Consumption":
    IF "Source Type" = "Source Type"::Item THEN
      ERROR(IsNotOnInventoryErr,"Item No.");
  "Entry Type"::Transfer:
    ERROR(IsNotOnInventoryErr,"Item No.");
  ELSE BEGIN
    Item.GET("Item No.");
    IF Item.PreventNegativeInventory THEN
      ERROR(IsNotOnInventoryErr,"Item No.");
  END;
END;


New Code
IF NOT Open THEN
  EXIT;
IF Quantity >= 0 THEN
  EXIT;
CASE "Entry Type" OF
  "Entry Type"::"Negative Adjmt.","Entry Type"::Consumption,"Entry Type"::"Assembly Consumption":
  //AK Start
  //IF "Source Type" = "Source Type"::Item THEN
  //      ERROR(IsNotOnInventoryErr,"Item No.");
    IF ("Source Type" = "Source Type"::Item) OR ("Source Type" = "Source Type"::" ") THEN
      ERROR(IsNotOnInventoryErr,"Item No.");
  //AK End

  "Entry Type"::Transfer:
    ERROR(IsNotOnInventoryErr,"Item No.");
  ELSE BEGIN
    Item.GET("Item No.");
    IF Item.PreventNegativeInventory THEN
      ERROR(IsNotOnInventoryErr,"Item No.");
  END;
END;