Hi,
I am trying to create the Javascript so that when a particular condition is filled it checks some fields to make sure there are values there. The code I am using is:
function Form_onsave(ExecutionObj)
{
saveMode = ExecutionObj.getEventArgs().getSaveMode();
Var shouldSave = false;
if(saveMode == 5)
{
if(status == 1)
{
if(Xrm.Page.getAttribute("new_BusinessClassification").getValue() == "Sole Trader")
{
if(Xrm.Page.getAttribute("new_dateofbirth").getValue())
{
shouldSave = True;
}
if(shouldSave == false)
{
if(Xrm.Page.getAttribute("new_fullnamerequired").getValue() == '')
{
if(Xrm.Page.getAttribute("new_fullhomeaddress").getValue() == '')
{
alert("Sole Trader Requires Additional Information");
executionObj.getEventArgs().preventDefault();
}
}
}
}
}
}
}
Basically I have an option set on the opportunity form and I need it to check if the Save event is triggered by a Close-Won and if this is a Sole Trader to ensure we have Name, Address and DOB details, when I have loaded this up onto the form then when I open the Opportunity Form I get a "Send Error report" error.
I am very new to using Javascript (About two days) so I am sure I am doing something wrong but I am not entirely sure what.
*This post is locked for comments
I have the same question (0)