locked
XRMSERVICETOOLKIT Null handling RRS feed

  • Question

  • Any way using this tool kit to have it return fields even if they are null.

    I hate to think of checking for the existence of each field before I use it.

    Thanks for any input

    Monday, July 8, 2013 8:04 PM

Answers

  • I created a function to recieve the entity and field name and return either null or a value depending on whether the field is in the query or not.

    //--------- 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 very effective. I'm sure there are other who could extend this further.

    • Marked as answer by bbuchanan Wednesday, September 24, 2014 1:23 PM
    Wednesday, September 24, 2014 1:22 PM