Tuesday, 18 February 2020

Upload file in azure storage account in D365FO

In this blog I will discuss how we can upload file in storage account in D365FO. We normally use azure storage account to hold thing that need to be further processed and stored on cloud.

Please see below code with explanation.

Explanation of source code (1.1):
  • Getting azure credentials from vend parameter tables.
  • Setting connection to access storage account.
  • Initialize cloud file client which used to configure and execute requests against the File service
  • Initialize cloud file share.
  • Check file share exists or not.












Explanation of source code (1.2):

  • Initialize cloud file directory which is directory of files which hold directories, and directories hold files.
  • Gets a reference to a virtual blob directory beneath this container.
  • Initialize cloud file.
  • Uploads a stream to a file. If the file already exists on the service, it will be overwritten.
















Complete Source Code (Method):

/// <summary>
    /// Upload file to azure file storage
    /// </summary>
    /// <param name = "_fileContentInStream">File stream</param>
    /// <parmam name = "_folderName">Folder where file saves</param>
    /// <param name = "_fileName">File name</param>
    /// <returns>True or False</returns>
    public static boolean uploadFileToAzureFileStorage(System.IO.Stream _fileContentInStream , str _folderName, str _fileName)
    {
        try
        {
            //Getting azure credentials from vend parameter tables (in my case)
            VendParameters  vendParameter = VendParameters::find();

            //Setting connection
            Microsoft.WindowsAzure.Storage.Auth.StorageCredentials storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials("Your storage account name",
                "Your storage account access key");
            Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
           
            //Provides a client-side logical representation of the Microsoft Azure File service.
            //This client is used to configure and execute requests against the File service.
            Microsoft.WindowsAzure.Storage.File.CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
           
            //Represents a share in the Microsoft Azure File service.
            Microsoft.WindowsAzure.Storage.File.CloudFileShare share = fileClient.GetShareReference("Your file share name");

            //If not exist throw error
            if (!share.Exists(null, null))
            {
                throw error(strFmt("File share not exists."));
            }

            //Represents a directory of files which hold directories, and directories hold files.
            Microsoft.WindowsAzure.Storage.File.CloudFileDirectory cloudDir = share.GetRootDirectoryReference();

            container conFolders = str2con(_folderName, '/');

            for (int i = 1; i <= conlen(conFolders); i++)
            {
                str folderName = conpeek(conFolders, i);

                //Gets a reference to a virtual blob directory beneath this container.
                cloudDir = cloudDir.GetDirectoryReference(folderName);
                cloudDir.CreateIfNotExists(null, null);
            }

            //Represents a file in the Microsoft Azure File service.
            Microsoft.WindowsAzure.Storage.File.CloudFile file = cloudDir.GetFileReference(_fileName);

            //Have to run Seek on Stream.
            if (_fileContentInStream.CanSeek)
            {
                _fileContentInStream.Seek(0, System.IO.SeekOrigin::Begin);
            }

            //Uploads a stream to a file. If the file already exists on the service, it will be overwritten
            file.UploadFromStream(_fileContentInStream, null, null, null);

            return true;
        }
        catch
        {
            return false;
        }
    }

That is all you have to do to upload files on azure storage accounts.

Tuesday, 4 February 2020

How to Effectively analyze ETA for any D365F&O Technical Task

I personally, and I'm sure almost all of you, heard questions like "When would it be ready? Or When will you deliver this task?" So in this blog I will discuss how I estimates time to accomplish D365F&O technical tasks.

Understand Customer Requirement:

Giving an ETA without understanding the task is like "Not knowing the destination of the ship and you estimates how long the trip takes". So in first place understanding the customer's requirement is most important.

Order Your Activities:

At this stage, you don't need to add in how long you think activities are going to take. However, you might want to note any important deadlines. For example, you might need to get documentation of another component of the system before starting integration.

Breakdown Your Estimates (into):

Known knowns: 
How long will it take to do what you know how to do. 

Known unknowns: 
How long do you think it will take to do what you don't know how to do.

Unknown unknowns: 
This is the real time black hole. Provide a range for the estimate with justification based on the risks you anticipate.

Offer to adjust the estimate and certain milestones along the way. Any "unknown unknowns" will become "known unknowns", the "known unknowns" should become "known knowns" as you gain experience, and the estimate of you "known knowns" can be adjusted based on progress to date. You can do an initial estimate, then re-estimate when you about 25% done, then again at 50%, then again at 85%. At each milestone your estimate should start converging on the actual time the tasks will take.

ETA Should Contains (as per the requirement from the client):

  • FDD Review
  • Development analysis
  • Coding
  • Run best practices + proper comments where needed
  • Unit testing
  • Quality assurance
  • Documentation (FRD, FDD, TDD, Test Cases, Release notes, Deployment document)
  • Code review
  • Build and Sync
  • Code merge or check-ins
  • Deployment (creating deployable package, deploying on other environments e.g., QA, CRP, UAT, Gold)
Examples For ETA:

Example # 1 - In this example ETA is not detailed or descriptive.




















Example # 2 - 
In this example ETA it is much detailed or descriptive.




















That is all, I believe this blog will add a value in your programming.

How to Get Customer Free Text Invoice "Totals" form field value with X++ in D365FO

Customer free text invoices are an essential aspect of financial management in D365FO. In this blog, I have compiled all the code needed to ...