且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

创建新表单后保存不会重新加载

更新时间:2023-12-05 11:49:10

要解决此问题,您可以执行以下操作:

  var saved = false; 

函数onLoad(){
checkIfFormShouldBeReadOnly();
attachEvent();
}

函数attachEvent(){
Xrm.Page.data.entity.addOnSave(executeOnSave);
}

函数executeOnSave(saveExecution){
if(!saved){
saved = true;
Xrm.Page.data.save()。then(
function(){
checkIfFormShouldBeReadOnly();
},
function(errorCode,message){
Xrm.Page.data.refresh();
}
);
}
}


working good in crm 2011 but not in crm 2013 online

On opportunity Entity create New record form i show only:

1.Some attributes(all other fields/Section/Tabs are hide on form)
2.and an Html button like

function OnFormLoad(){   
  if(Xrm.Page.ui.getFormType() == 1 ) {

     SetRequiredLevelToNone();

     createHtmlButton("Save");

     HideTabsAndSections()    

  }
  else {    

  }
}

On click of Html button following function is triggered.

function showWholeForm() {
  Xrm.Page.data.entity.save();
}

I want to show all the fields of form after save, means want to reload whole form.
As working in crm 2011

To fix this you can do:

var saved = false;

function onLoad(){
    checkIfFormShouldBeReadOnly();
    attachEvent();
}

function attachEvent() {
    Xrm.Page.data.entity.addOnSave(executeOnSave);
}

function executeOnSave(saveExecution) {
    if (!saved) {
       saved = true;
       Xrm.Page.data.save().then(
          function () {
             checkIfFormShouldBeReadOnly();
          },
          function (errorCode, message) {
             Xrm.Page.data.refresh();
          }
       );
   }
}