Showing posts with label Tips Tricks. Show all posts
Showing posts with label Tips Tricks. Show all posts

Saturday, November 28, 2009

How to block New, Edit and View actions in the ListPage

In Microsoft Dynamics NAV RT Client, pages has default actions like New, Edit, View and etc…imageIn the ListPage, New action is promoted and shown in the New Promoted Category. This action is not promoted in the card part. 

image According to my requirement, I do not want New promoted action in the listpage. This can be achived by customizing the Actions like the following:

image image

But this process should need to be done in every client. The same requirement can be achieved by modifying the TIF information.

For Customer List Example: Remove the CardFormID field value in the TIF information for the Customer List and transform the page to form..

image image image

Limitations: Double clicking the Customer List will not open the Customer Card (Standard Functionality). Work around is to create a new action to open the Card and promote this action.

image

SAVERECORD and UPDATE

In Microsoft Dynamics NAV, CurrForm.SAVERECORD or CurrPage.SAVERECORD is used to save the current record shown on the form/page. CurrForm.UPDATE(True or False) or CurrPage.UPDATE(True or False) is used to save the current record based on the parameter and updates the controls in the form/page.

Using the two functions together in the form/page does not give any error normally but error will be displayed in pages if the following code is called before inserting the record.

CurrPage.SAVERECORD();//Which save the record.
CurrPage.UPDATE;//Which updates the controls.

For Example: Add the above lines of code in the Type – OnValidate() in the “46 Sales Order Subform” page and try to insert the sales line.

image This is because above set of code is trying to insert the record in two places one is using SAVERECORD and second is UPDATE (even though Parameter is FALSE).

Friday, November 27, 2009

How to read BLOB data and export into a File

In Microsoft Dynamics NAV tables, we can create BLOB fields to store large amount of data. It is not possible to read the data in the BLOB fields directly.

The following steps shows the procedure to read the BLOB data. In this example, I have taken “User Metadata” table to read the data in the “Page Metadate Delta” field.

1) Create a codeunit with the below variables.

Name DataType Subtype Length
UserMetadata Record User Metadata  
Data InStream    
Line Text   1024
Pos Integer    
File1 File    

2) Add the following code to the codeunit.

image 3) Save and Run the codeunit. Text file will be created in the given path with the data in the BLOB field.

Thanks,

Veerendra CH.

Saturday, October 24, 2009

How Run button in Object Designer opens the page in the RTC

In the NAV 2009 SP1, it is possible to run the Page from the Object Designer.

image In the Object Designer, Run button will open the related page in Role Tailored Client. I think this is achieved using the HYPERLINK function in Navision.

HYPERLINK function passes a URL as an argument to an Internet browser.

By adding the following code in OnPush Tirgger of any button will open the related page in Role Tailored Client.

HYPERLINK('DynamicsNAV:////runpage?page=' + FORMAT(ID));

Here ID valud should be Page ID.

The above code can also be applied to open the reports in Role Tailored Client.

HYPERLINK('DynamicsNAV:////runreport?report=' + FORMAT(ID));

The above line of code can be added to any form/page to open the pages/reports dynamically.

Transformation Tool: Subfrom Menu Items to Pages

Using Transformation Tool it is possible to transform forms to pages in NAV 2009.
Forms like Sales Order, Purchase Order has Line Menu Button in the Main from and Transformation Tool automatically transforms the Line Menu button to the Sub page (ListPart). If the Menu Button has any Menu Items, Transformation Tool will also move the Menu Items to the Sub page.

Logic behind this is,Transformation Tool moves the Menu Item to Sub page if it finds the code like “CurrForm.subform.FORM.FunctionName” in the Onpush of the menu item.
Sales Order—>Line—>Reservation Entries, OnPush trigger has the following code.
CurrForm.SalesLines.FORM.ShowReservationEntries;
image

For example if you want a confirmation message before opening the reservation entries, you can write the code in the function or you can write like below:
IF CONFIRM(Text123,TRUE) THEN
  CurrForm.SalesLines.FORM.ShowReservationEntries;

If the code is like above, Transformation Tool will not move this Reservation Entries menu item to sub page. It will create a new Line menu button in the main page and add the Reservation Entries menu item to that.
image
TIP: If your requirement needs to write code before calling the function in the subform, maintain the code in single line like the following:
IF CONFIRM(Text123,TRUE) THEN CurrForm.SalesLines.FORM.ShowReservationEntries;