Handling null fields

Jul 8, 2013 at 9:17 PM
Is there a way to have fields that are listed in the soap columns return null instead of just not appearing in the list.

I have about 50 fields in a soap call and I really don't what to have to wrap them all in if statements.

Thanks for any input.
Jul 31, 2013 at 11:15 AM
Hi There.

You should only return the values which are required for better response time and performance. I guess if you do need to retrieve all 50 fields. You can use conditional expression like the following

var fooNotNull = (foo !== null) ? true : false;

Hope this helps.
Jul 31, 2013 at 6:01 PM
I Meant to post this earlier but here is a piece of code I created to test fields.

//--------- scripts Related to the XRM Service Toolkit
// Return the value of a field
// Receives the XRM entity object and the field name
// Returns either the value or null if the field is not there
function xrmfieldtest(entity, field) {
if (entity.attributes[field]) {
    return (entity.attributes[field].value);
} else {
    return null

Simple but effective this way I can get nulls if I need them without much trouble.

I only request the fields I need. The entity I'm working with has over 700 fields. But even if requested null fields are not returned.