Hi,
I'm new to JavaScript and debugging client side, and I'm experiencing some issues while debugging, I'm trying to understand whether my code is incorrect or they depend on Crm configuration.
I have multiple JavaScript functions added in the Form Properties of my Entity:
So that when I load my entity record form and open the Chrome inspector, I can inspect all of them and debugging.
- First, are there any criteria to decide which of these functions will be run first (in other terms: should I worry about it?) or is totally up to the browser? I noticed that the order I added in the Form Properties doesn't matter: the function onLoad of library 2 runs first.
- Secondly, when I debug FunctionToAddFilter and do a WebApi call, as soon as I step out from the RetrievMultipleRecords asynchronous callback and press Resume Script Execution I'm redirected to the onLoad function of library 2 again.
If I press Step over Next function I'm redirected to the Pretty-Print minified file.
Why I'm redirected to the previous file instead than being redirected inside the success/error callBackFunction? May it depend on configuration, i.e. having multiple OnLoad functions added to the same form?
This is the complete code, including the asynchronous call:
function myFunction(executionContext) { debugger; var formContext = executionContext.getFormContext(); var collectionid = formContext.data.entity.getId(); var fetchFilter = ""; Xrm.WebApi.retrieveMultipleRecords("new_movie", "?$select= directorid, new_name&$filter=new_collectionid eq" collectionid).then( function success(result) { debugger; for (var i = 0; i < result.entities.length; i ) { var directorid = result.entities[i]["directorid"]; var directoridToUpper = directorid.ToUpperCase(); var directoridToUpper2 = "{" directoridToUpper "}"; // add {} to Guid and letter capitalization fetchFilter = "" directoridToUpper2 ""; } fetchFilter = ""; formContext.getControl("new_defaultdirectorid").addPreSearch(function () { formContext.getControl("new_defaultdirectorid").addCustomFilter(fetchFilter); }) }, function (error) { debugger; Xrm.openAlertDialog("error: " error.message); } ); }
Hi, Joel D.
-"First, are there any criteria to decide which of these functions will be run first"
The excecution order in dynamics firts load Native Code, then custom code from TOP to DOWN on ONLOAD.
-"Why I'm redirected to the previous file instead than being redirected inside the success/error callBackFunction?"
remember Xrm.WebApi.retrieveMultipleRecords is a Promise that means that the function you don't know when but sure you will get back a reponse.