Exchange Rate Loader PowerApp for D365 F&O - Part 2

 In the second part of this blog I will detail some adjustments I made to the app, this include the additional logic for:

1. Add some messaging back to user to let them know if there is any errors.
2. Put some kind of wait bar to give users idea of progress.

Firstly to manage the messaging back to the user for both status and error I added two text fields and labels into the APP:

Error field and Label has been added and I have modified the "Visable" parameter to only show if "failed" or "PartiallySucceeded" which is some of the data I pass back to the app from the flow:



Status field and Label has been added and I have modified the "Visable" parameter to only show for all status's. This is because when the app starts there is no status defined:


I also modified the upload control as well visible parameter as I want this to only show when app is not actively loading:


I also added a spinner which is detailed here, PowerApps Tips and Tricks - Create loading spinners, add comments, make your life easier, and more! - YouTube the spinner GIF can be downloaded for free from loading.io - Your SVG + GIF + PNG Ajax Loading Icons and Animation Generator the spinner visible is controlled via a parameter VarSpinner which I set here:


 


As well as this I added updated the onaddfile parameter to set the parameter for both visible on the Error, Status, Upload control and spinner when the flow runs:

Set(VarVisable,false);

Set(VarSpinner,true);

Set(varAzureFile, AzureBlobStorage.CreateFile("powerapploader",Last(UploadControl.Attachments).Name, Last(UploadControl.Attachments).Value));

Collect(varFiles, {FN: Last(UploadControl.Attachments).Name, FL: BlobStorageAccount & BlobContainer & varAzureFile.Path, FID : varAzureFile.Id});

Set(varFromFlow,'PowerApps->DataPackageAPI'.Run(EnviromentName,DataEntity,LegalEntity,BlobStorageAccount,varAzureFile.Name,BlobContainer,PackageHeader,Manifest));

Reset(UploadControl);

Set(VarSpinner,false);

Set(VarVisable,true);

This gives me a result like below when app is started:


When the app is running we get this:


Then when APP completes we get this, Status field always shows but the error field only shows based on there being errors:


To pass back the Status and the Error messages to Power Apps from D365 F&O I made some adjustments to the flow which sits behind the upload button, these steps I added before the delete file as I didn't want that to delay sending information back to user:


Firstly I initialized a Boolean variable to do a check on the status: 


I used a do until to check the value of the status, as I was finding it was returning the intial status of the load and not the final status, I am using the D365 F&O connector to retrieve the status and a condition to set the variable to true once the status requirement is met.


After this I am retrieving the error messages if there are any using the D365 F&O connector:


Then I am parsing the JSON body to get the error message:


Then is is passed back to PowerApps using the step below:


To get the values into PowerApps I made another slight adjustment to the onaddfile parameter on the upload control:

Set(VarVisable,false);

Set(VarSpinner,true);

Set(varAzureFile, AzureBlobStorage.CreateFile("powerapploader",Last(UploadControl.Attachments).Name, Last(UploadControl.Attachments).Value));

Collect(varFiles, {FN: Last(UploadControl.Attachments).Name, FL: BlobStorageAccount & BlobContainer & varAzureFile.Path, FID : varAzureFile.Id});

Set(varFromFlow,'PowerApps->DataPackageAPI'.Run(EnviromentName,DataEntity,LegalEntity,BlobStorageAccount,varAzureFile.Name,BlobContainer,PackageHeader,Manifest));

Reset(UploadControl);

Set(VarSpinner,false);

Set(VarVisable,true);

Then finally I modified the Error and Status to display the data passed back to PowerApps:




This means now that when user runs the APP and the there is any load which is status of "Failed" or "PartiallySucceeded" then it will show error and status, for all others it shows just the status.

In the future parts of this blog I will cover off the following:

1. Put some logic in to allow concurrent loads as currently only supports single person executing at the same time.
2. Allow for dynamic naming of files.
3. Provide a downloadable excel template for users so they can see the required format.

Thats alls for now



































Comments

Popular posts from this blog

"Exception while trying to get Virtual Entity metadata for entity" Error on Data Events

Electronic Reporting displaying Legal Entity Email/Phone by custom Address Purpose

Custom Connector for HMRC VAT Number Validation