setFocus problem in MSCRM 2011 RRS feed

  • Question

  • Hi All ,

    I am using setfocus (onload) to focus one field in the form . When the form is fully loaded and when I press Esc button it give a message to Save or Discard the changes ,but none of the fields are getting dirty. I commented setfocus line alone and its working as expected. So now I need to focus that field , I have used document.getElementid().focus but it didn't work .

    please Suggest.



    Tuesday, August 26, 2014 4:45 AM

All replies

  • Hi Jyothi,

     What is the datatype of the field? Setfocus does not make any field dirty.

    please run the following code on "onsave" and see if you are getting any alert when you click save after setting focus. This method will tell you the dirty fields.

    function extractBlackSheeps() {
        var attributes = Xrm.Page.data.entity.attributes.get();
        var dirtys = '';
        for (var i in attributes) {
            var attribute = attributes[i];
            if (attribute.getIsDirty())
                dirtys = dirtys + attribute.getName() + " ";
        if (dirtys != '')



    Tuesday, August 26, 2014 4:53 AM
  • Thanks Jithesh for the code.

    I have checked this code but none of the fields were getting dirty 'onSave' also.

    Actually in the form I am focusing one field which becomes required field after certain conditions .

    Tuesday, August 26, 2014 5:16 AM