crm2013 - Form js: save() does a save, but does NOT reload the saved record ... RRS feed

  • Question

  • Hi all, 

    in crm2011 we had a js formchanger based on a filed value (new_recordtype). This worked (the form loads twice .. once for loading the record with last used form, then detecting the value of the new_recordtype-field and load the form again, but this time the right one.

    Now we want the same functionality in crm2013, but there are some strange things going on.

    If i open an existing record, the formchanger works still fine (like the explanation above) ..


    If a create a new record or if i change the value of the new_recordtype-field, then the onchange-event of the new_recordtype-field makes a js: save(). 
    The save is executed, but the form does no reload. 
    I mean to see that there is no reload, because the onload event of the form will not executed.

    I hope my explanation is ok und someone has the same issue or  a solution for this.

    many many thx.

    Greets Pit


    after the save that will be executed in the onchange of the new_recordtype-field there a 2 different things happen:

    - if i load an existing record, and change the value of the new_recordtype-field, the changed field is shown after the save, but the onload of the form will not executed.

    if i create a new record, fill the number and new_recordtype-field, the save will be executed an the record is shown in the gridview, but after the save, the "New Record"-Form will be shown (i think because, the form onload will not be executed) .. and the enterd number and new_recordtype-field values are NOT shown in the "New Record"-Form.
    If i open the newly created record form the gridview, the entered data will showed correctly and the form reload works fine.

    Tuesday, October 29, 2013 3:58 PM

All replies

  • Hi again, 

    does anyone understand my problem ... and maybe have a hint, why the onload part of the formular didnt fire on reload of the form.. ?

    thx, greets pit

    Wednesday, October 30, 2013 9:32 AM
  • Hi, I answered it on the other forum... Did this help?

    I haven't tried it myself, but in your case you could trigger a function on the onChange event and change your code a little bit.

    From your attribute's onChange event, try to call the new Xrm.Page.data.save method that will allow you to call another function asynchronously after the record is actually saved!

    Quote from the SDK: Xrm.Page.data.save().then(successCallback, errorCallback)

    Declare 2 additional functions successCallback and errorCallback.

    In the successCallback, check your attribute's value and switch the form if necessary (as you do in the onLoad event, or just call the same function that you call in the onLoad event).

    Wednesday, October 30, 2013 5:34 PM
  • Hi Frederic, 

    sorry, no that didnt solve my problem.

    Maybe i have a new approach:

    If i save the changed field "new_recordtype" .. the onchange of this field executes the js: "save()".
    in crm2011 this was running good.

    in crm2013 the save will be done, but i think, there will be done no reload of the saved data form the db and the changed data of the field "new_recordtype" is gone too. 

    Because after the form was saved, there are two different situations, which are doing not the thing i want:

    by creating a new record, the save will be done in onchange of the field "
    new_recordtype", the i ve seen that the form reload works .. BUT ONLY shortly. .. the reload of the correct form (which is the entry in "new_recordtype") will be done, but immediately reloads again to the "NEW RECORD" Form .. and this is wrong.

    by opening an existing record, the form-relad works (this is ok).. if then changing the value in field "
    new_recordtype" .. the js:onchange "save()" will be executed too, but in this case nothing happens. The save will be done, but no reload of the form .. which should be done on js:onload of the Form. 

    So i think the onload will not be excetuted, but only in point 2. In Point 1, the reload is done, but another reloads makes it wrong.

    any other solutions?

    THX, Greets Pit

    Monday, November 18, 2013 3:07 PM
  • no more Solutions?
    Wednesday, November 20, 2013 8:01 AM