D365 Finance and Operation Scripting

Learn advanced scripting techniques for asynchronous operations in Microsoft D365 Finance & Operations using StresStimulus.

Microsoft D365 F&O, Scripting Tips


Transcript

Welcome to StressStimulus video training. In this video, I will show you two techniques you should use in performance testing Microsoft Dynamics 365 for finance and operation. One is how to handle scenarios with asynchronous server operations using conditional loops to prevent script from failing. Many D365 F O transactions, such as those in the approval workflow, are implemented asynchronously. To make its load-testing script work, you would need to use conditional loops. I will also show another technique for detecting specific application errors using Validators, also known as assertions. I will record a scenario showing two steps in the approval workflow of a purchase order here: confirmation and product receipt. While navigating through the UI, I will give you a heads-up on what changes I will make in this script. After completing the recording, I will show you how to configure them. In StressStimulus I click on the recorder to start the recording wizard. Enter a test case name: Confirm & Receive PO. Select a web browser, Microsoft Edge. Entered the URL and the name of the first transaction, Landing page. Click here to open the browser and start recording. In the StressStimulus recorder, add transaction Login and enter credentials. Once the application loads, add transaction All POs and navigate to the purchase order grid. Transaction Search PO and paste the PO number 20. Transaction Select PO. The next Transaction is Confirm P O. This page displays the Processing dialog when this asynchronous Operation starts on the server. It is designed to wait until Confirm operation completes and the processing dialog closes. The challenge is that if the script is replayed as recorded, it will fail because during the test execution, the server processing timing will be off. To fix this issue, the page wait timing must be dynamically adapted to match server responsiveness during playback. So I will add a conditional loop that polls the server to check when the Operation is complete before proceeding, Let's continue recording. The next transaction is Product Receipt. Navigate to the Receive tab and click the Product receipt link. In the receipt name box, enter the P O number. The Next Transaction is Product Receipt OK. This OK button for posting the product receipt appears here only after completing the previous Confirm transaction. So I can create a validator that checks the presence of this button to determine whether the previous transaction has been completedThe Processing dialog appears again when this asynchronous operation starts on the server. I will also add a loop around this transaction. The trick is to know that the dialog, just before closing for a fraction of a second, displays the text, Operation completed. I will configure both loops to break when this text is found in the server response. OK. We recorded the two P O approval workflow steps and can Log out now. Click the stop button to end the recording. No manual correlation is required, as Stresstimulus correlation is fully automatic. It is completed now. However, if I play back this script as recorded, it will still fail because it will try to confirm the already confirmed PO we recorded, which is not permitted by the application constraint. So, I must parameterize the recorded P O with a dataset. This way a different P O will be confirmed each time. Navigate to the dataset section. Click the import button. I will use a CSV file. Enter the path of the Purchase Order file. Click next with all defaults until the last step to create the dataset, Purchase Orders. Change its default binding mode to VU iteration-bound to use a different P O number every time. Next search the requests for the recorded P O number 20. StressStimulus highlights such requests. Right-click the first one and select Create a Parameter. In the parameter window, right-click the highlighted value and replace it with the dataset column, Item Number. Click OK to create more parameters like this one in other requests. Now let’s add a response validator to ensure the OK button is visible on the product receipt page. First I will find a response to validate. That OK button is downloaded in a JSON response containing text: Name, semicolon, and OK. Right-click this highlighted request and select Create Validator. In the validator dialog, enter the OK button's JSON representation in the text-to-search field. The error Description is - PO Confirm failed. The error will appear when the button is not found. Now let’s verify the script by playing it back to check the approval of the P O from the dataset. The verification shows a validator error PO Confirm failed. We expected that because as I mentioned the timing of the asynchronous operation during the playback was off. Now I will show you how to fix it by adding a conditional loop. First, we need to find the asynchronous operation requests. Search the responses with the text "operation completed" which appeared for a fraction of a second in the Processing dialog we discussed. StressStimulus highlights 2 responses that correspond to the Confirm and Receive operations, respectively. Right-click the first one, select Create Container and click Create Do While, which is a conditional loop.Set the max number of repeats to 30In the search expression, enter Operation-Completed to break the loop when the asynchronous operation completes on the server.I will create the same conditional loop for the receive operation.Verify again to ensure that the script works correctly now. This time, the verification reported no errors. Let's also check the PO's status in the browser. I searched for P O number 21 from the dataset. The status changed to Confirmed and Received, so now the script works.The techniques we learn today are not tool-specific as they address scripting challenges predicated by this application scenario. So they need to be resolved regardless of what load-testing tools you use. If you have a highly customized D365 F O instance, your script may require other settings. All such configurations are resolved on StressStimulus scripting support sessions. Let's review the main takeaways. Use conditional loops in scripts for D365 FO asynchronous operations. Use validators for detecting application errors. Scripting sessions to resolve issues in your custom application instance can be scheduled from the StressStimulus application. Thank you for watching.