You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was retrieving multiple records of a custom entity with the version which uses Callbacks.
My code is like the following:
var dynamicsWebApi = new DynamicsWebApi({ webApiVersion: '8.2' });
var filter = 'new_myfield eq <a_value>';
var select = ['new_field_1', 'new_field_2', 'new_field_3', 'new_field_2'];
dynamicsWebApi.retrieveMultiple('new_myentity', function (result) {
//My Logic
}, function (err) {
Xrm.Utility.alertDialog(err.message)
}, select, filter);
new_field_1, new_field_2, new_field_3, new_field_4 are all of type "Single Line of Text" (String)
I was retrieving a record which had new_field_2, new_field_3, new_field_4 empty (no value for the fields).
In run-time, entering the function 'populateFormattedValues(object)', the object has a null value for each of the corresponding keys:
function populateFormattedValues(object) {
var keys = Object.keys(object);
for (var i = 0; i < keys.length; i++) {
//Below object[keys[i]] is null for the empty fields on CRM
if (object[keys[i]].constructor === Array) {
for (var j = 0; j < object[keys[i]].length; j++) {
object[keys[i]][j] = populateFormattedValues(object[keys[i]][j]);
}
}
...
As a consequence, an exception is thrown because the code is trying to evaluate the property "constructor" of a null object.
I fixed the issue by adding a skipping step for the null elements, as shown below:
function populateFormattedValues(object) {
var keys = Object.keys(object);
for (var i = 0; i < keys.length; i++) {
if (object[keys[i]] == null)
continue;
if (object[keys[i]].constructor === Array) {
for (var j = 0; j < object[keys[i]].length; j++) {
object[keys[i]][j] = populateFormattedValues(object[keys[i]][j]);
}
}
...
After this fixing, the code is running properly, returning the correct object with parameters.
I would suggest you to make a deeper check and, in case, fix the code as I did or in a better way, and then publish the fixed version of the library.
Anyhow, congratulations for the very good job!
The text was updated successfully, but these errors were encountered:
Hi Alexandr.
Many thanks for your quick answer and opening an already closed issue.
I was convinced to use the last version, but it seems not, therefore Monday I’ll go to download the last one.
Again good job!
Daniele Davi
+49 152 02197349
Il giorno 01 dic 2017, alle ore 16:56, Aleksandr Rogov ***@***.***> ha scritto:
What version are you using? I see that it has been fixed in v.1.3.1. #13
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Hi Alexandr.
I was retrieving multiple records of a custom entity with the version which uses Callbacks.
My code is like the following:
var dynamicsWebApi = new DynamicsWebApi({ webApiVersion: '8.2' });
var filter = 'new_myfield eq <a_value>';
var select = ['new_field_1', 'new_field_2', 'new_field_3', 'new_field_2'];
dynamicsWebApi.retrieveMultiple('new_myentity', function (result) {
//My Logic
}, function (err) {
Xrm.Utility.alertDialog(err.message)
}, select, filter);
I was retrieving a record which had new_field_2, new_field_3, new_field_4 empty (no value for the fields).
In run-time, entering the function 'populateFormattedValues(object)', the object has a null value for each of the corresponding keys:
function populateFormattedValues(object) {
var keys = Object.keys(object);
As a consequence, an exception is thrown because the code is trying to evaluate the property "constructor" of a null object.
I fixed the issue by adding a skipping step for the null elements, as shown below:
function populateFormattedValues(object) {
var keys = Object.keys(object);
After this fixing, the code is running properly, returning the correct object with parameters.
I would suggest you to make a deeper check and, in case, fix the code as I did or in a better way, and then publish the fixed version of the library.
Anyhow, congratulations for the very good job!
The text was updated successfully, but these errors were encountered: