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

Category Archives: D365 Business Central

How to send Email Notification to Users using Workflow in Dynamics NAV

Introduction: Many a times in an Approval workflow, we need to notify the user by email to the Approver that approval request is sent also the sender needs to be notified whether the approval request sent is approved or cancelled. Hence, we need to setup Email Notification. Pre-requisites: Microsoft Dynamics NAV 2016 Office 365 Account Steps: 1. Setup SMTP Mail Setup Navigate to SMTP Mail setup from the Search bar. Click on Apply Office 365 Server Settings. Enter the UserID and Password (This is the sender’s email id. Mostly company email) 2. Setup Notification Template and Notification Setup Navigate to Notification Template and set Notification Method to E-mail for Type Approval Navigate to Notification Setup, for Notification Type Approval Schedule it Instantly.It can also be schedules Daily, Weekly, Monthly 3. Setup emails in the Approval User Setup In the Approval User Setup, enter the email id of each user in the email field. 4. Enable Mail Notify Job Queue. Navigate to the Job queue and enable Notify Job queue. The Mail Notify job queue is a standard job queue. When workflow is triggered having response Send approval request for the record and create a notification, Notification Entry is created in the Notification entries Record. This job fetches records from Notification entries and sends email to the recipient. The sent email can be viewed in the Sent Notification Entries page. Note: Delete the pre-existing Notification Entries of users with no email id or entries prior setting up emails 5. Sending email to the approver from workflow I’ve enabled standard Purchase Quote workflow. Open Purchase Quote and click on Send Approval Request. The status of the Purchase Quote changes to Pending Approval A notification email is sent to the approver.

Share Story :

How to send Notes to the Customer from a Custom Page using an Action button in Dynamics NAV

Business central from Dynamics 365 is an ERP solution from Microsoft which is designed to understand your business needs and change it for better.  Dynamics 365 business central development is a business management solution that is extremely easy to use and implement across several domains in your organization. Business central is the cloud version of the Dynamics NAV Platform. Which is being implemented by many companies across various industries in almost every part of the world. This cloud based ERP is designed for small and medium businesses which allows you to focus on your core business needs and strategies without having to invest on any infrastructure and installation. Implementation of Dynamic 365 business central to your organization helps you to connect your business and make smarter decisions. Introduction: The requirement is explained in the Scenario below: Scenario: A Custom page called Collection Module-Per User has details of Customers Transaction. This Collection Per User page is a List page. The User will select the line and Click on Notes. Notes will written and saved. The user will Click on the Action button Send Notes to Customer.TheNotes from this Custom page should be sent to standard page Customer (Page 18) Notes in Microsoft Dynamics NAV: Notes are like reminders or notification which is ideally used for Customers,Vendors or Items.  Notes are saved in binary format in a field Note of Blob data type in the table Record Link  (2000000068) Read notes : The “Record ID” of the record using Record Reference is used to filter the Record Link table and convert the data stored in the Note field in Record Link table to text. Write Notes: The “Record ID” of the record using Record Reference is used to filter the Record Link table and convert the text to bytes and store in the Note field Pre-requisites: Microsoft Dynamics NAV 2017 Steps: Functionality: 1. Select the line in the Custom page and click on Notes. Type in your Notes and Save it. 2. Click on Send Notes to Customer. 3. Open the Customer page and filter the Customer No to which Notes are sent and Open Notes. Customization: 1. Create an Action button Send Notes to Customer and create global variables as below image: 2. The Custom Table has primary key as No. so first GET the primary key and assign Customer No. to a variable Rec_CustNo ReadText: Rec_CF_CollectionModuleTempTable.GET(No); Rec_CustNo:=Rec_CF_CollectionModuleTempTable.CustNo; Set the Recfilter and use the Recorf reference to GETTABLE. Rec_CF_CollectionModuleTempTable.SETRECFILTER; CLEAR(RecRef); RecRef.GETTABLE(Rec_CF_CollectionModuleTempTable); RecRef.FINDFIRST; 3. SETRANGE with the Record Link’s Table Record ID and Record referrence RECORDID 4. Convert the blob field into text by using InStream and Use a BigText variable to read the Stream. RecordLink.RESET; RecordLink.SETCURRENTKEY(“Record ID”); RecordLink.SETRANGE(“Record ID”,RecRef.RECORDID); IF RecordLink.FINDFIRST THEN BEGIN RecordLink.CALCFIELDS(Note); IF RecordLink.Note.HASVALUE THEN BEGIN CLEAR(NoteText); RecordLink.Note.CREATEINSTREAM(Stream); NoteText.READ(Stream); NoteText.GETSUBTEXT(NoteText,2); END; END; Write Text: 1. GET the Customer No. of the Cuatomer Table and Use Record refernce to GETTABLE Customer. Use SetText function to write the text to bytes and store it in Note field in Record Link Customer.GET(Rec_CustNo); RecRef.GETTABLE(Customer); RecordLink.INIT; RecordLink.”Link ID”:=0; RecordLink.”Record ID”:=RecRef.RECORDID; RecordLink.URL1:=GETURL(CLIENTTYPE::Windows,COMPANYNAME,OBJECTTYPE::Page,PAGE::”Customer”); RecordLink.Type:=RecordLink.Type::Note; RecordLink.Created:=CURRENTDATETIME; RecordLink.”User ID”:=USERID; RecordLink.Company:=COMPANYNAME; RecordLink.Notify:=TRUE; SetText(NoteText,RecordLink); RecordLink.INSERT; The Complete Code : Send Notes to Customer – OnAction() Rec_CF_CollectionModuleTempTable.GET(No); Rec_CustNo:=Rec_CF_CollectionModuleTempTable.CustNo; //MESSAGE(‘%1 no’,Rec_CF_CollectionModuleTempTable.CustNo); Rec_CF_CollectionModuleTempTable.SETRECFILTER; CLEAR(RecRef); RecRef.GETTABLE(Rec_CF_CollectionModuleTempTable); RecRef.FINDFIRST; RecordLink.RESET; RecordLink.SETCURRENTKEY(“Record ID”); RecordLink.SETRANGE(“Record ID”,RecRef.RECORDID); IF RecordLink.FINDFIRST THEN BEGIN REPEAT RecordLink.CALCFIELDS(Note); IF RecordLink.Note.HASVALUE THEN BEGIN CLEAR(NoteText); RecordLink.Note.CREATEINSTREAM(Stream); NoteText.READ(Stream); NoteText.GETSUBTEXT(NoteText,2); MESSAGE(FORMAT(NoteText)); END; UNTIL RecordLink.NEXT=0; END; Customer.GET(Rec_CustNo); RecRef.GETTABLE(Customer); RecordLink.INIT; RecordLink.”Link ID”:=0; RecordLink.”Record ID”:=RecRef.RECORDID; RecordLink.URL1:=GETURL(CLIENTTYPE::Windows,COMPANYNAME,OBJECTTYPE::Page,PAGE::”Customer”); RecordLink.Type:=RecordLink.Type::Note; RecordLink.Created:=CURRENTDATETIME; RecordLink.”User ID”:=USERID; RecordLink.Company:=COMPANYNAME; RecordLink.Notify:=TRUE; SetText(NoteText,RecordLink); RecordLink.INSERT; PROCEDURE SetText@1000000002(NoteText@1000000000 : BigText;VAR RecordLink@1000000001 : Record 2000000068); VAR s@1000000002 : BigText; Ostr@1000000003 : OutStream; lf@1000000004 : Text; c1@1000000005 : Char; c2@1000000006 : Char; x@1000000007 : Integer; y@1000000008 : Integer; i@1000000009 : Integer; SystemUTF8Encoder@1000000011 : DotNet “‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Text.UTF8Encoding”; SystemByteArray@1000000010 : DotNet “‘mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.System.Array”; BEGIN s := NoteText; SystemUTF8Encoder := SystemUTF8Encoder.UTF8Encoding; SystemByteArray := SystemUTF8Encoder.GetBytes(s); RecordLink.Note.CREATEOUTSTREAM(Ostr); x := SystemByteArray.Length DIV 128; IF x > 1 THEN y := SystemByteArray.Length – 128 * (x – 1) ELSE y := SystemByteArray.Length; c1 := y; Ostr.WRITE(c1); IF x > 0 THEN BEGIN c2 := x; Ostr.WRITE(c2); END; FOR i := 0 TO SystemByteArray.Length – 1 DO BEGIN c1 := SystemByteArray.GetValue(i); Ostr.WRITE(c1); END; END; LOCAL PROCEDURE HtmlEncode@20(InText@1000 : Text[1024]) : Text[1024]; VAR SystemWebHttpUtility@1001 : DotNet “‘System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.System.Web.HttpUtility”; BEGIN SystemWebHttpUtility := SystemWebHttpUtility.HttpUtility; EXIT(SystemWebHttpUtility.HtmlEncode(InText)); END;

Share Story :

Explore Business Central API through Postman using Basic Authentication

Introduction: In this article, we will walk through steps on how to authenticate Business Central API using Basic Authentication in Postman Pre-Requisite: Business Central account Business Central API Basic authentication in Postman: In Postman, make a GET request to Business Central base API URL. Base URL: https://api.businesscentral.dynamics.com/v1.0/api/beta For using Basic Authentication, we need to add domain as well. Domain URL: https://api.businesscentral.dynamics.com/v1.0/myusersdomain.com/api/beta In Business Central, generate Web Service Access Key for your user. Now in Postman authorization tab, select Basic Auth in Type. Provide Username and Web Service Access Key Click Send

Share Story :

Setup Positive Pay Export

Introduction: What is Positive Pay Export and Why it’s used? Positive Pay Export is a file that is given to the bank to verify the Cheques that have been printed. Whenever the company wants to issue any payment to Customer or a Vendor, it is done with the help of Payment Journals. After creation of Payment Journal lines, the check is printed through a Report.  After the creation of the Check in the Bank Account there is an action called as PositivePayExport. This file is a text file and contains the information related to the Cheques printed and it is given to the bank. Every bank has their format which is used to automatically verify the Cheques that are being issued. Pre-requisites: Microsoft Dynamics NAV 2017 Demonstration: 1. Creating a Bank Account: To issue the cheque setting up Bank Account is mandatory. 2. Setting up the Data Exchange Definitions: Data Exchange Definition is used to set up the format for Positive Pay Export. The format for Export: Create a new Data Exchange Definition: Creating Column Definitions: Column Definition is the sequence in which the data is to be generated as per the format. Creating a Line Definitions: Line Definitions are used to map the System Fields to the fields in the column definitions. In the Line Definition, there are transformation rules that are used to modify the data that is exported into the format. Create a Line Definition and Select Field Mapping. There are some predefined Transformation Rules as well as new transformation Rules can be created. I’ve created the following transformation rules. I’ve shown the details of REPLACE transformation rule 3. Connecting the Data Exchange Definition with the Bank Account: To link the Positive Pay Export and the Bank Account, go to Bank Accounts and select the Positive Pay Export Code. 4. Creating Payment Journal Entries, Printing Cheques and Exporting the Positive Pay file. Creating Payment Journal Entry Printing the Check Report Positive Pay Export in Bank Account KEY4679 After Exporting Positive Pay Export the values generated in Positive Pay Export file are as follows. 000003296812746790000000012201805150000010200 000003296812746790000000013201805150000010512

Share Story :

How to Send Mail with attachment using Streams for reports with request page in Dynamics NAV

Scenario: On Customer Master page, an action button is created called Email customer, on click of the action button, an email has to be sent to the respective customer with attachment of the invoices in a .pdf format. Here, the report is saves as .pdf file. This report has a request page where Start Date and End date are entered by the user. Based on the date ranges, invoices generated for the particular user is mailed to the customer. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: 1. Create a global function on the Customer master page to make a call to the codeunit. Here the Customer No. is passed as a parameter. 2. In the Function InvoiceMail, declare a parameter  CustNo. and the variables as follows: Here CustTempTable is a Temporary table The Code is added as follows: InvoiceMail(Custno : Code[20]) -Function Name SMTPMailSetup.GET; CustomerTable.RESET; CustomerTable.SETRANGE(“No.”,Custno); IF CustomerTable.FINDFIRST THEN BEGIN EmailID:=CustomerTable.”E-Mail”; CF_FTLCustomerInvoice.SETTABLEVIEW(CustomerTable); XmlParameters:=CF_FTLCustomerInvoice.RUNREQUESTPAGE(); CustTempTable.Parameters.CREATEOUTSTREAM(OStream,TEXTENCODING::UTF8); CustTempTable.Parameters.CREATEINSTREAM(IStream,TEXTENCODING::UTF8); REPORT.SAVEAS(50011,XmlParameters,REPORTFORMAT::Pdf,OStream); CLEAR(SMTPMail); SMTPMail.CreateMessage(”,SMTPMailSetup.”User ID”,EmailID,’Invoice Statement from CompanyName‘,”,TRUE); SMTPMail.AddAttachmentStream(IStream,’Customer Invoice’+ CustomerTable.Name+’.pdf’); SMTPMail.AppendBody(‘Hi ‘+CustomerTable.Name+’,’); SMTPMail.AppendBody(‘<br>’); SMTPMail.AppendBody(‘Please find attached your Customer Invoice statement’); SMTPMail.AppendBody(‘<HR>’); SMTPMail.AppendBody(‘This is a system generated mail. Please do not reply to this mail!’); SMTPMail.Send; MESSAGE(‘Mail sent to Customer %1’,Custno); END; Explaination of the code: 1. Set the SMTL Mail setup in the Role Tailored Client. Click on Apply Office 365 Server Settings. Add the Sender email (comapny email in my case) in User ID field and password of the email id in the Password field. 2. Store the Customer Email in the Email ID variable. 3. Pass the filters applied to the CustomerTable to the report variable CF_FTLCustomerInvoice. 4. Run the request page. The Run request page passes the request parameters in an xml format which is stored in a text variable XmlParameters. 5. Create an OutStream to save the the XmlParamters received in a File Parameters in a .xml format. 6. Create Instream to read the .xml file. 7. REPORT.SAVEAS(50011,XmlParameters,REPORTFORMAT::Pdf,OStream); saves the xmlparameters from the outsream in an pdf format. 8. Use SMTPMail.CreateMessage function to enter the sender’s and receipient’s  email, Subject  etc. 9. Add the attachement from the InputStream. 10. Draft a body of the email and Use SMTPMail.Send to Send the email. Yay.Email is Sent! Execution: 1.Click on Action button, Request page opens. 2. Enter the Start date and End date and click on OK. 3. An email is sent to the customer. Conclusion: Overview of the blog, first setup the SMTL Mail setup. Create an action button and create a function call. In the function defination, code as above and email is sent

Share Story :

How to change the font colour of a List page based on a condition in Dynamics NAV

Intoduction: The requirement was such that, based on a condition certain lines should appear in Red.This can be done by using page control Style Property. The Style property has ten values that apply different formats to field text as below: Value Format Standard Standard StandardAccent Blue Strong Bold StrongAccent Blue + Bold Attention Red + Italic AttentionAccent Blue + Italic Favorable Bold + Green Unfavorable Bold + Italic + Red Ambiguous Yellow Subordinate Grey Pre-Requisites: Microosft Dynamics NAV 2017 Steps: 1. Create a global variable i.e. on the View menu, choose C/AL Globals. 2. Define the variable, and then set the DataType to Boolean. 3. Open the Property of the variable then set the IncludeInDataSet to Yes. (I’ve use CFS_Repo as my boolean field). 4. Create a local function. (in my case UpdateStyle). 5. Now, code in the function. My requiremnt was such that if field  RepoInitiated is true then the line should should appear red. You can code as per tour requirement. 6. On the trigger OnAfterGetCurrRecord, call the function. 7. Now select the Field in the List page and click on Properties (Shift + F4) 8. Set the Style to Unfavorable and StyleExpr to CFS_Repo (the boolean field ) 9. Repeat the step 8 for all fields present on the list page.

Share Story :

How to update the selected line in the Subform on click of an action button in the Mainform in NAV

Introduction: The requirement was such that , the user will select a line in the subform. The subform has fields like the Customer ID, Customer Name, and a field Recieved Crates. On click of the action button in the Main form, a page opens which contains the details of the selected line in the subform  like Customer ID and Customer Name also a field Crate recieved(Integer Datatype). User will enter Crate Recieved and click on OK. The number entered in the Crate received will modify in the Recieved crates field in the subform. This blog explains the step wise procedure to achieve the above output. Pre-Requisites: Microsoft Dynamics NAV 2017 Steps: 1. Open the Developement Environment of Microsoft Dynamics NAV and open the Main form(card Page) and create an action button Received Crate and write the below code. Here, “Crate Lines” is the Page control (subform), Here a call is made to CallLinesfromCard  function with Parameter CratesLine. CallLinesfromCard is a global function made in “Crate Lines”Subform. 2. In the function CallLinesfromCard  in the subform. Below is the code. Here ReceiveCrate is a page. Its the page that open on click of the action button. A function is called CrateReceivedFromCust with parameter CrateLinesTable. 3. A global function is made CrateReceivedfromCust in the page ReceiveCrate. Here global fields variables are made CustomerID,CustomerName,NoOfcratesShipped. Theses fields are autopopulated with values from the selected line. A field Crates Received is also created where the user will enter data. 4. OnQueryClosePage of Receive Page, below code is written to modify the Record of the Subform. 5. Set the property RefreshOnactive to yes on the Subform and Mainform.

Share Story :

How to restrict an action button based on time in Microsoft Dynamics NAV

Introduction: Scenario- The requirement was such that on click of the action button a payment transaction is done. The time at which transaction was done is stored in the database. A restriction shouldto be applied to disallow the customer to make payment for the same amount till a certain time E.g. A transaction was  done by customer A at 11.40 a.m for amount $100. This customer will be disallowed to make the transaction of the same amount $100 till suppose 5 mins. This time is mins will depend on the client requirement. Pre-requisites: Microsoft Dynamics NAV 2017 Steps: A field is added in the Sales & recivable setup for Time Check in mins. Here, time in minutes is entered say 5 mins. So the payment will be restricted for 5 mins. I’ve written the code on the action button. EFTTransaction.RESET; EFTTransaction.SETRANGE(“Store No.”,’xyz’); EFTTransaction.SETRANGE(“Terminal No.”,’TERM01′); EFTTransaction.SETRANGE(“Sell-to Customer No.”,Rec.”Sell-to Customer No.”); EFTTransaction.SETRANGE(“Account Number”,Rec.”Account Number”); EFTTransaction.SETRANGE(“Transaction Amount”,Rec.”Transaction Amount”); EFTTransaction.SETRANGE(“Transaction Status”,EFTTransaction.”Transaction Status”::Approved); IF EFTTransaction.FINDLAST THEN BEGIN time1:=EFTTransaction.”Transaction Time”; Create Integer variables Hours, Minutes and Seconds and Milliseconds as Decimal variable. Get the transaction time. Time by default is stored in the system in milliseconds. The below code will convert time and store the hour in Hour variable, minutes in Minutes variable and same for seconds. //Code written to convert time to hr min and sec **ST** Milliseconds := time1 – 000000T; //MESSAGE(‘%1 total mili’,Milliseconds); Hours := Milliseconds DIV 1000 DIV 60 DIV 60; Milliseconds -= Hours * 1000 * 60 * 60; Minutes := Milliseconds DIV 1000 DIV 60; Milliseconds -= Minutes * 1000 * 60; Seconds := Milliseconds DIV 1000; Milliseconds -= Seconds * 1000 ; //Code written to convert time to hr min and sec **EN** Get the Time check in mins from Sales & recivable setup and add it up with the Minutes variable. “Rec_Sales&Rec”.GET; Minutes+=”Rec_Sales&Rec”.”Time Check for Credit Card(min”; Now we have till which the transaction should be restricted but the time is stored in Integer variables. Write the below code to convert the integer/decimal variable to time. Milliseconds+=Seconds*1000 +Minutes * 1000 * 60+Hours * 1000 * 60 * 60; //convert time to milliseconds Milliseconds:=Milliseconds/1000; //convert milliseconds to seconds tim := 000000T; tim := tim + (Milliseconds MOD 60) * 1000; // get the seconds Milliseconds := Milliseconds DIV 60; // keep the minutes tim := tim + (Milliseconds MOD 60) * 1000 * 60; // get the minutes Milliseconds := Milliseconds DIV 60; // keep the hours tim := tim + (Milliseconds MOD 60) * 1000 * 60 * 60; // get the hours Here we get our time in time variable. Add the restriction condition. IF (EFTTransaction.”Transaction Date”=TODAY) AND (TIME < tim) THEN ERROR(‘The Transaction for the account number %1 can be only done after %2 mins’,Rec.”Account Number”,”Rec_Sales&Rec”.”Time Check for Credit Card(min”) ELSE BEGIN Submit; “Submit&Settle”; Conclusion : Thus using the above logic time can be converted to Integer variables and then convert Integer variables to time again.

Share Story :

Getting the source code of the .app extension in Microsoft Dynamics Business Central

Objective: This blog demonstrates how to get the source code of the extension app installed in Microsoft Dynamics Business Central. Pre-requisite: Docker Microsoft Dynamics 365 Business Central on Container Nav-Container Helper Module installed in Powershell Demonstration: 1. List the Docker Container: Command: docker ps 2. Entering the Container: Command:   Enter-NavContainer <Container Name> 3. List all directories in Container: Command: dir / ls 4. As Extensions are stored in C:\Extensions getting into Extension directory Command: i. cd C:\Extensions ii. dir 5. Exit the Container: Command: exit 6. Copy the .app file inside the container to local path: Command: docker cp <Container Name>:C:\Extensions\<Filename><LocalDirectory> 7. Make a copy & rename the file with .rar as extension 8. Extract the .rar file and explore the ‘src ‘ folder to get the source code in .AL files Conclusion: Thus, in this way the source code is visible and can be used for reference.

Share Story :

How to setup D365 Business Central?

Introduction: The much awaited Dynamics 365 Business Central officially released on 2 April 2018. We are often used to creating virtual machines and setting up Microsoft Dynamics NAV but D365 Business Central doesn’t require a VM, we can set it up on Azure and use it locally. Pre-requisites: Microsoft Azure Licence File Steps: 1. Create a resource group in Microsoft Azure. I have named it navbc. 2. Click on NAVBC resource group and open Azure cloud shell Enter the below command az container create –name MDBC  –image “microsoft/dynamics-nav:12.0.21229.0″ –resource-group NAVBC –os-type Windows –cpu 2 –memory 3 –environment-variables ACCEPT_EULA=Y USESSL=N LICENSEFILE=” ” –ip-address public –port 80 443 8080 7049 Here, –name: your container name –resource-group: your resource group name –environment-variables ACCEPT_EULA=Y – mandatory parameter. –ip-address public: mandatory LICENSEFILE=” ” : Here upload your licence to the cloud and then copy the link. –port: list of ports. 8080 is a default value. Use 7049 port number to download symbols whichout which you cannot connect VS code to your container Open your Resource group, the container instace is created click on the instance. This will open the container instance overview page. This will take quite some time approx 15-30 mins get your container instance running. For more information on azure commands click https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quickstarthere 3. To get the container infomation enter the below command az container logs –resource-group navbc –name mdbc 4. Download .vsix file Open your container Instance you will find your IP address. copy it. Copy the link under Files http://<containerIP>:8080/al-0.15.18771.vsix and replace b08..  with the conatiner IP address.This will download your .vsix file. now launch your VSCode and click on Extensions. Install .vsix and AL Language for D365 BC. 5. Publish an Extension Open the launch.json file and replace the server with “http://containerip”. Download symbols using command Ctrl+P Build(ctrl+shift+B) the package and publish it! (Ctrl+ F5). Yay! Now the final step open D365 Business Central. (http://containerip/NAV) This will prompt you for User name and pass word and bang D365 Business Central opens.

Share Story :

SEARCH BLOGS:

FOLLOW CLOUDFRONTS BLOG :


Secured By miniOrange