locked
Javascript question RRS feed

  • Question

  • I have a simple javascript function to clear all the fields on the form.  I execute it on a multi select value change.  The problem is that it also clears the multi select value.  I can't stop it from doing this.  Here is my code, I try to only clear the field if it is not equal to the actual field triggering the event.  Where am I messing this up?

    function ClearAllFields() {
        var attributes = Xrm.Page.data.entity.attributes.get();
        for (var i in attributes) {
            if (attributes[i].getName !="vs_feescheduletype")
    {
              attributes[i].setValue(null);
            }
        }
    }

    Wednesday, October 22, 2014 6:23 PM

Answers

  • Hey ONeil, 

    I guess the issue is with the getName function. You missed the "()" in the function call. Hope this helps.

    function ClearAllFields() {
        var attributes = Xrm.Page.data.entity.attributes.get();
        for (var i in attributes) {
            if (attributes[i].getName() !="vs_feescheduletype")
    {
              attributes[i].setValue(null);
            }
        }
    }


    Thanks & Regards, Johninfant

    • Proposed as answer by Johninfant Friday, October 24, 2014 4:01 AM
    • Marked as answer by M.ONeill75 Friday, October 24, 2014 1:59 PM
    Friday, October 24, 2014 4:01 AM

All replies

  • multi select check list implementation has two parts, a picklist and a value field. Your code des not exclude these fields from clearing.

    regards

    Jithesh

    Wednesday, October 22, 2014 9:24 PM
  • Hey ONeil, 

    I guess the issue is with the getName function. You missed the "()" in the function call. Hope this helps.

    function ClearAllFields() {
        var attributes = Xrm.Page.data.entity.attributes.get();
        for (var i in attributes) {
            if (attributes[i].getName() !="vs_feescheduletype")
    {
              attributes[i].setValue(null);
            }
        }
    }


    Thanks & Regards, Johninfant

    • Proposed as answer by Johninfant Friday, October 24, 2014 4:01 AM
    • Marked as answer by M.ONeill75 Friday, October 24, 2014 1:59 PM
    Friday, October 24, 2014 4:01 AM