Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 123975

Forum Post: Open new form and Close the old one

$
0
0

I would like to save the form, open the new one and close the old one.

I had issue with Firefox: the new form is not opening because the whole window is closed before. 

So I modified the code and now I'm having another issue: The old form is not closed!

What I'm doing wrong here? Any help would be appreciated.

Here's my code, I commented the necessary pieces:

var isMandatoryEmpty = checkMandatoryFields();

if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
Xrm.Page.data.entity.save();

//I'm doing this because Xrm.Page.data.entity.save("saveandclose"); would close everything and the new form would not be opened (firefox)
} else {
Xrm.Page.data.entity.save("saveandclose");
}
if (!isMandatoryEmpty) {
Xrm.Utility.openEntityForm("task", null, parameters);
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
Xrm.Page.data.entity.save("saveandclose"); //Closing the old form here for Firefox (but it is not closed)
//Xrm.Page.ui.close();
}
}

//are there Required fields that are empty?
function checkMandatoryFields() {
var isMandatoryEmpty = false;
var attributes = Xrm.Page.data.entity.attributes.get();
for ( var i in attributes) {
if (attributes[i].getRequiredLevel() == "required" && attributes[i].getValue() == null) {
isMandatoryEmpty = true;
break;
}
}
return isMandatoryEmpty;
}


Viewing all articles
Browse latest Browse all 123975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>