locked
CRM 2011: Setting the field value when form Load RRS feed

  • Question

  • Hi,

    I am trying to solve the following scenario.

    Scenario:

    "When a form is opened I need to make a call to webservice, compare that data with one of the field value in the form, if the data is different I need to update the field value. All this should happen without interfering with user".

    Setup:

    The current setup is,

    a) JavaScript function is registered with OnLoad event of the form

    b) I have included the following script in the function

        if(currentValue != fetchedValue)
        {
                 Xrm.Page.getAttribute('field').setValue('fetchedValue');
                 Xrm.Page.data.entity.save();
                 window.location.reload(true);              
        }

    Although the above script set the value of the field, it threw the error as shown in the image and all the fields required for the user to take action became disabled.

    Can some one please suggest on this. Thanks!

    Friday, February 14, 2014 5:25 AM

All replies