Hi Henry,
Thanks for responding back.
I am doing 2 different types of Api save.
1) In my opinion formContext.data.entity.save(saveOption) should work.
My first save looks like this. I am displaying a dialog.
var displayMessage = "Are you sure you want to assign this case to the engineer?";
var confirmStrings = { text: displayMessage, title: "Assign To Engineer" };
var confirmOptions = { height: 80, width: 260 };
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function (success) {
if (!success.confirmed) {
(formContext.getAttribute("new_isassigntoprojectengineer")).setValue(false);
return;
}
*** This is not working ***
//formContext.data.save({saveMode: 2});
//formContext.data.entity.save("saveandclose");
formContext.data.save().then(function() {
formContext.ui.close();
});
},
);
I tried Xrm.Page.data.entity.save("saveandclose");
in the browser F12 console and it works as expected: it saves the data and then closes the form (your code did work too).
Just asking. Are you working with model-driven-app?
Maybe consider opening a case to help troubleshoot this: https://admin.powerplatform.microsoft.com/support
I did open a case spoke with Microsoft not much help. Even show them the issue.
2) Could you elaborate on what you're trying to achieve and how?
What is the event associated with your function?
My event is triggered on "OnSave".
I've never seen Xrm.Page.BooleanAttribute
, so I'm not sure it's a supported method.
I am using typescript (d.ts) for CRM.
You should consider removing Xrm.Page from your code and replace it with formContext, as it is deprecated.
Yes I am using "formContext" and not "Xrm.Page".
3) Can you also elaborate on this, maybe with more details of your code and a bit of background on what you are trying to achieve?
My second save is an event "OnSave".
formContext.data.save().then(function () {
addDocumentFieldToEntity(formContext);
StartCreatingFromWebResources(formContext);
});
function StartCreatingFromWebResources(formContext: any) {
//Not working
Xrm.Utility.showProgressIndicator(displayMessage);
//I do have a timer on this
Xrm.Utility.closeProgressIndicator();
});
I was able to find what was causing the Xrm.Utility.showProgressIndicator not to work.
I changed the code to do the following.
var displayMessage = "Saving Data Sheet Template. Please Wait...";
Xrm.Utility.showProgressIndicator(displayMessage);
window.setTimeout(function () {
/// Using Timeout of secs, to close the progress Indicator
Xrm.Utility.closeProgressIndicator();
},47000);
setTimeout(function () {
var caseDataSheetTemplateUpdateEntity = new CaseCommon.CaseDataSheetTemplateUpdateEntity();
addDocumentFieldToEntity(formContext, caseDataSheetTemplateUpdateEntity);
StartCreatingFromWebResources(formContext, caseDataSheetTemplateUpdateEntity);
}, 1000);