D365 Business Central Archives - Page 25 of 32 - - Page 25

Category Archives: D365 Business Central

Modifying the Primary keys of records in NAV

Introduction: This blog demonstrates how to modify the non-key fields with respect to the key fields. Pre-requisites: NAV 2017 Demonstration: Generally, when modifying the records, the syntax used is Record.FieldName := New_Value; Record.MODIFY(TRUE); In order to do modify the Key fields of the table, we need to know the order in which the keys are assigned. To modify the primary key, the syntax used is Record.RENAME(Key1,Key2,Key3); Where, Key1 corresponds to value that is supposed to be assigned to ‘No.’ field. Key2 corresponds to value that is supposed to be assigned to ‘LineNo.’ field. Key3 corresponds to value that is supposed to be assigned to ‘Leased to Driver No.’ field. Even when the single key field is to be changed, all the key fields should be present in their sequential order. If there is any mismatch in the number of keys, NAV throws the following runtime error. Note: Renaming operation is a costly operation. Creating a New record and Deleting the old record is faster as compared to Rename. In case where the performance is the requirement, the second method is preferred.

Share Story :

How to hide the Delete button in a page in Microsoft Dynamics NAV

Introduction: By default, Delete button is visible on every page in the Home tab but if we do not want the user to delete any record from the page then we need to hide this delete button. This article explains how to hide the Delete button from the Home tab of  page. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. Open the Microsoft Dynamics NAV Development Environment, navigate to the List Page where you want hide the delete button and go to properties of the page. 2. Set the DeleteAllowed property to No.  3. Repeat the step 1 and 2  for the Card page 4. Save and Compile the page. 5. We can hide the Edit button by setting InsertAllowed to No and ModifyAllowed Property to No  

Share Story :

Workaround to Report.SAVEASPDF in NAV 2018

Objective: In NAV 2017 Emailing the PDF by running the report using Report.SAVEASPDF is now not allowed in NAV 2018. The reason is that temporary server file as not allowed to be saved for some security reasons. Thus this blog demonstrates the workaround solution for this issue. Pre-requisite: NAV 2018 Demonstration: 1. Concept: With respect to NAV 2018, Microsoft says that Emailing the attachments should be done using Streams. Thus, we’ve to convert the PDF generated by running the report into a stream and pass the stream as an attachment (https://community.dynamics.com/nav/f/34/t/270046). Before running the report, the data needs to be passed appropriately to the Report. Report.RUNMODAL method cannot be used as running report requires XML Parameters. For this, we make use of XMLParameters that are sent to the report through either a request page or as XML Text which contains a list of parameters to be passed and then the report is run. 2. Procedure: Step1: Generate the XMLParameters(Text) using the RUNREQUESTPAGE method and copy the results. REQUESTPAGE is used to set the filters prior to running the report. The filters selected are passed to the report in XML format. Value in XMLParameter: Here, Rec.Contract No. is the primary filter to be passed to the report. Step2: Create the Instream and Outstream variables and a temporary table having BLOB field. Create the OutStream variable for the BLOB field of the Temporary Table. Save the data of OutStream variable using Report.SaveAs method. Copy the data of the BLOB field to Instream Step 3: Pass the attachment as a Stream using Instream Note: Perform the Step 1 only if there is any filter to be applied to the report. Conclusion: This workaround is to be used where the Report.SAVEASPDF cannot be used because this method is not allowed in AL.

Share Story :

Error Resolution to “Form.RunModal is not allowed in write transaction” in Microsoft Dynamics NAV

Introduction: Scenario: I had created an action button Print to run a report using REPORT.RUNMODAL, while running this report from the Windows Client an error is thrown as below. Pre-requisites: Microsoft Dynamics NAV 2017 Cause of this error: RUNMODAL stops the  transaction and waits for the User interaction. Hence, all users are blocked (who need the table). During a transaction, we are not allowed to open a object with RUNMODAL. Resolution to the error: Use COMMIT statement before you call the REPORT.RUNMODAL. What does COMMIT statement do? When the system enters a C/AL codeunit, it automatically enables write transactions to be performed. When the system exits a C/AL code module, it automatically ends the write transaction by committing the updates made by the C/AL code. This means that if you want the C/AL codeunit to perform a single write transaction, the system automatically handles it for you. However, if you want the C/AL codeunit to perform multiple write transactions, you must use the COMMIT function to end one write transaction before you can start the next. The COMMIT function separates write transactions in a C/AL code module. Example The metasyntax below contains two write transactions. As execution begins, a write transaction is automatically started. Using the COMMIT function, you tell the system that the first write transaction has ended and prepare the system for the second. Once execution has been completed, the system automatically ends the second write transaction. BeginWriteTransactions (C/AL Statements) // Transaction 1 COMMIT (C/AL Statements) // Transaction 2 EndWriteTransactions

Share Story :

Blanket Sales Order Dynamics NAV

Introduction: A blanket sales order represents a sales agreement between the company and a customer. It typically involves one item with multiple shipments at predetermined quantities, price and delivery dates. Scenario: Customer orders 500 units of item that will be delivered 100 units for each week. Steps: 1) In the Search box, enter “blanket Sales orders”, and select the related link. 2) Click on new to create new blanket Sales order. 3) On the General FastTab, in the Sell to Customer No. field, select Customer. 4) Keep the Order Date field blank. When the separate Sales orders are created from the blanket order, the program will set the order date of the Sales order equal to the current date. 5) On the Lines FastTab, in the Type field, select Item. 6) In the No. field, select item. 7) In the quantity field, specify quantity 100. 8) Specify date in Shipment Date field. 9) Create four more lines and specify 100 quantity and shipment date in each line. 10) Now in Qty. to Ship field, keep the quantity of 100 for the first line and delete the quantity to ship in the other four lines. 11) On the Home tab, click Make Order. 12) Click Yes to create an order. 13) You will get message that a Sales order is created from the blanket order. 14) To open the Sales order, select the first line on Blanket order. 15) On the Lines FastTab, point to Line, then to Unposted Lines, and then click Orders. 16) On Home tab of the Sales Lines page, click Show Document. Then the Sales order will appear. Conclusion: By using Blanket Sales Order organization can sell a specified quantity or amount by using multiple Sales orders over time.

Share Story :

Bug fixing for the error ‘The request for path /NAV2018/dev/apps failed with code 422.’

Introduction: Work around to solve the error ‘The request for path /NAV2018/dev/apps failed with code 422. Reason: The value “1473493” can’t be evaluated into type Date’. This is a bug accepted by Microsoft. Thus this blog demonstrate the workaround to the bug until it gets fixed. Pre-requisite: NAV 2018 Demonstration: Converting the text files to AL files from C/AL suing TEXT2AL utility, Thus, InitValue property of the field is set as per the C/AL object but, it throws the following error Workaround to this is either comment out the code and validate the field and add the data. Conclusion: This is a bug and the following method is only a quick fix until a new version is released.

Share Story :

Saving the Data of NAV 2018 after upgrading the extension in Visual Studio Code

Introduction: In NAV 2018, after installing the extension the data of the newly created fields using extension is to be filled. But after upgrading the extension the data of the added field gets flushed out. Thus, this blog demonstrates how to configure to prevent the data from getting flushed. Pre-requisites: NAV 2018 CU2 along with its Installation DVD Zip Demonstration: Goto Visual Studio Code and uninstall the previous version AL Language Extension. Install the extension from AL Language from the path “C:\Users\<Username>\Downloads\CU 02 NAV 2018 NA\NAV.11.0.20348.NA.DVD\ModernDev\program files\Microsoft Dynamics NAV\110\Modern Development Environment/ALLanguage.VSIX” file. Select the .VSIX file. Reload the AL Language Extension. Adding the following lines to ‘launch.json’ file If the data is to be saved :-  “schemaUpdateMode”: “Synchronize” If the data is to be flushed :- “schemaUpdateMode”: “Recreate” Conclusion: This feature wasn’t included NAV 2018 and the data used to get flushed everything the extension was upgraded. Thus, the data flushing issue was resolved in NAV 2018 CU2 version.

Share Story :

How to avoid data deletion when Dynamics NAV 2018 extension is published from VS Code

Introduction: There was a bug till NAV 2018 CU 1 update that whenever a NAV 2018 extension is published from VS Code, all the data which was inserted earlier gets deleted. Pre-requisites: Microsoft Dynamics NAV 2018 CU 2 Visual studio code (VS Code) Steps: 1. Install Microsoft Dynamics NAV 2018 CU 2 2. Install VSIX Extension for VS Code Click on Extension button at the Left corner of VS code. Click on the more button ( three dots) and select Install from VSIX. Navigate to the path  “CU 02 NAV 2018 NA\NAV.11.0.20348.NA.DVD\ModernDev\program files\Microsoft Dynamics NAV\110\Modern Development Environment” to install VSIX. 3. Open the launch.json file and enter schemaUpdateMode to synchronize How data synchronization works? The data synchronization between each publish is controlled by schemaUpdateMode setting, which is specified in the launch.json. This setting consists of two options; Synchronize and Recreate. The default value for schemaUpdateMode is set to the Synchronize mode, which means that every time you publish an extension to the development server, the data you entered previously stays. If you do not want to synchronize the sample data with each publish, you can change the schemaUpdateMode setting from Synchronize to Recreate Recreate mode: When you set the schema update mode to Recreate, all the tables and table extensions are recreated at every publish, which means that all the data in those tables are lost. This means that you will get empty records when you publish your extension.

Share Story :

Deferral of Income & Expenses in Navision

Introduction: Microsoft Dynamics NAV allows you to set up deferrals of income and expenditure. These allow you to post transactions into a particular month but then spread the financial effect over a number of periods in a way you can specify. This article explains how to set up and use this functionality. Set up: First, you need to create a Deferral Template which will define how the deferral will work. To do this, type “deferral template” in the top right hand corner of the screen and open the Deferral Template list. You should see a screen like the following:- Either click on Edit to modify an existing template or New to create a new one.  You should then see the following screen:- Fill in the fields as follows:- Deferral Account – This is the GL Account code the deferral will initially be posted to.  This would normally be a Balance Sheet account; Deferral % – How much of the initial posting is to be deferred (can be from 1% to a maximum of 100%); Calc. Method – How the deferral will be calculated.  This can be one of:- Straight-Line, where an equal amount will be applied per period from the Starting to Ending Dates specified in the schedule; Equal per Period, where an equal amount will be deferred per period; Days per Period, where the amount deferred per period is based on the number of days in that period as a proportion of the total number of days in the whole deferral period; User-defined, where the amounts for each period are entered manually. Start Date – This can be one of:- Posting Date, the Posting Date of the document that generates the deferral; Beginning of Period, the beginning of the period in which the document is posted; End of Period, the end of the period in which the document is posted; Beginning of next period. No. of Periods – How many periods the deferral will be spread over. These are only default values, as we shall see later they can be amended on individual transactions if necessary. The next step is to assign the template to transactions. The simplest way to do this is to assign it to either a G/L Account, Resource or Item.  To assign it to a G/L Account, open the Chart of Accounts list, click on the account you wish to set the template for and click on the Edit button.  You should see the following screen:- On the Posting tab, set the Default Deferral Template as required. You can now start to use the Deferral functionality.  We will use a purchase order as an example.  Create a new purchase order and add a line for the G/L Account code you assigned the Default Deferral Code to.  Add a Quantity of 1 and a Direct Unit Cost. Use the Choose Columns functionality to make sure you can see the Deferral Code field.  By default, you should able to see the code as in the screen shot below. You can add, delete or change the code if you wish. To see the effect the posted deferral will have over time, drill down on the Line button below the Lines caption on the page and click on the Deferral Schedule option. The following screen should appear:- You can amend the deferral amount and dates and change the spread of the amounts over time if needed.  If you do make any changes, you may need to click on the Calculate Schedule button at the top of the page to recalculate the deferral amounts. Now receive and invoice the order. Note: You will need to set the Posting Date range on either your User Setup record or the General Ledger Setup date range to allow you post up to the last period the deferral will cover. If you do not, you will see an error message that a Posting Date is not within the allowed posting date range. Now bring up the Posted Purchase Invoice you created when you invoiced the order and click on the Navigate button.  If you view the G/L Entries for the invoice you should see something like the following:- As you can see, the cost has been posted to the deferrals g/l account rather than the account specified on the purchase order and the first month has then been reversed out and posted to the original account in accordance with the deferral schedule. Note that you cannot see the reversals of the deferral over the subsequent month of the schedule. To display these, remove the filter of the Posting date by clicking on the red x button immediately to the left of it.  You should now see the following screen:- Conclusion: As you can see, this shows the original entries and the entries that reverse out the deferral over the period of the deferral schedule. This Feature of Deferral is Available after NAV 2016 version only.

Share Story :

Creating a Control Add-in using Javascript and calling it in AL.

Introduction: In NAV 2017, control add-ins were called through .NET code which is imported as .ZIP files. With NAV 2018 .NET is not supported in extensions. Thus we’ve to perform the following steps to make a Control Add-in in Javascript. Pre-requisite: 1. NAV-2018 2. VS Code Procedure: Create a Startup script as start.js: Startup scripts are loaded whenever the NAV object containing the control add-in starts. Basically, the startup scripts are used for initialization. Create a Javascript file as demo.js : Contains most of the logic that the control add-in performs.  Create a control add-in object in AL: Control Add-in objects are used by NAV to register the control add-in and events and procedures on which the control add-in works. Create a NAV object using AL: This object generally contains the control add-in integrated into the standard, created or customized NAV objects. This object acts as the starting point where events are performed. Output: Added Control Add-In: Invoking on INIT: Script Invoking on Event: Conclusion: Thus, we can create control add-in using Javascript and access in NAV .AL objects using extensions

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange