9. Februar 2016 15:53
function Form_onload()
{
// Get the field that fired the event.
var oEstValue = crmForm.all.estimatedvalue;
var oProbability = crmForm.all.closeprobability;
var oWeightedValue = crmForm.all.advis_weightedvalue;
var oCloseDateChange = crmForm.all.advis_closedatechange;
var oLastCloseDateChange = crmForm.all.advis_lastclosedatechange;
var currentUser = crmForm.all.ownerid.DataValue[0];
var userId = currentUser.id;
var userName = currentUser.name;
//var ms = oCloseDateChange .valueOf() - oLastCloseDateChange .valueOf();
//var minutes = ms / 1000 / 60;
//var hours = minutes / 60;
//var days = hours / 24;
//if (days < 7)
//{
//oWeightedValue.style.backgroundColor = "#FF0000";
oWeightedValue.style.color = "#FF0000";
//}
// Validate the field information.
//if (typeof(oEstValue) != "undefined" && oEstValue != null)
//{
// if (typeof(oProbability) != "undefined" && oProbability != null)
// {
// oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
// }
//}
// Disabling Fields
oWeightedValue.Disabled=true;
oWeightedValue.ForceSubmit = true;
crmForm.all.advis_closedatechange.Disabled=true;
crmForm.all.advis_lastclosedatechange.Disabled=true;
crmForm.all.advis_estvaluechange.Disabled=true;
crmForm.all.advis_lastestvaluechange.Disabled=true;
// Hiding Fields
crmForm.all.stepname_c.innerText = "";
crmForm.all.stepname.style.display = "none";
}
function advis_projectid_onchange()
{
}
function salesstagecode_onchange()
{
// Get the field that fired the event.
var oSalesStage = event.srcElement;
var oProbability = crmForm.all.closeprobability;
var oEstValue = crmForm.all.estimatedvalue;
var oWeightedValue = crmForm.all.advis_weightedvalue;
crmForm.all.stepname.DataValue = oSalesStage.SelectedText;
// Validate the field information.
if (typeof(oProbability) != "undefined" && oProbability != null)
switch (oSalesStage.DataValue)
{
case "200000":
{
oProbability.DataValue = 0;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
break;
}
case "200001":
{
oProbability.DataValue = 20;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue *oEstValue.DataValue/100;
break;
}
case "200002":
{
oProbability.DataValue = 50;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
break;
}
case "200003":
{
oProbability.DataValue = 50;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
break;
}
case "200004":
{
oProbability.DataValue = 75;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
break;
}
case "200005":
{
oProbability.DataValue = 90;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
break;
}
case "200006":
{
oProbability.DataValue = 100;
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
break;
}
}
}
function isrevenuesystemcalculated_onchange()
{
}
function estimatedvalue_onchange()
{
// Get the field that fired the event.
var oEstValue = event.srcElement;
var oProbability = crmForm.all.closeprobability;
var oWeightedValue = crmForm.all.advis_weightedvalue;
var oChange = crmForm.all.advis_estvaluechange;
var oLastChange = crmForm.all.advis_lastestvaluechange;
var today = new Date();
// Validate the field information.
if (typeof(oEstValue) != "undefined" && oEstValue != null)
{
if (typeof(oProbability) != "undefined" && oProbability != null)
{
oWeightedValue.DataValue = oProbability.DataValue*oEstValue.DataValue/100;
}
if (typeof(oChange) != "undefined" && oChange != null)
{
oLastChange.DataValue = oChange.DataValue;
oChange.DataValue = today;
}
else
{
oChange.DataValue = today;
}
}
}
function estimatedclosedate_onchange()
{
var oEstCloseDate = event.srcElement;
var oChange = crmForm.all.advis_closedatechange;
var oLastChange = crmForm.all.advis_lastclosedatechange;
var today = new Date();
// Validate the field information.
if (typeof(oEstCloseDate) != "undefined" && oEstCloseDate != null)
{
if (typeof(oChange) != "undefined" && oChange != null)
{
oLastChange.DataValue = oChange.DataValue;
oChange.DataValue = today;
}
else
{
oChange.DataValue = today;
}
}
}
function Form_onload()
{
// Get the field that fired the event.
var oEstValue = Xrm.Page.getAttribute("estimatedvalue");
var oProbability = Xrm.Page.getAttribute("closeprobability");
var oWeightedValue = Xrm.Page.getAttribute("advis_weightedvalue");
var oCloseDateChange = Xrm.Page.getAttribute("advis_closedatechange");
var oLastCloseDateChange = Xrm.Page.getAttribute("advis_lastclosedatechange");
var currentUser = Xrm.Page.getAttribute("ownerid").getValue()[0];
var userId = currentUser.id;
var userName = currentUser.name;
//var ms = oCloseDateChange .valueOf() - oLastCloseDateChange .valueOf();
//var minutes = ms / 1000 / 60;
//var hours = minutes / 60;
//var days = hours / 24;
//if (days < 7)
//{
//oWeightedValue.style.backgroundColor = "#FF0000";
//oWeightedValue.style.color = "#FF0000";
//}
// Validate the field information.
//if (typeof(oEstValue) != "undefined" && oEstValue != null)
//{
// if (typeof(oProbability) != "undefined" && oProbability != null)
// {
// oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
// }
//}
// Disabling Fields
//oWeightedValue.setDisabled(true);
oWeightedValue.ForceSubmit = true;
Xrm.Page.getControl("advis_closedatechange").setDisabled(true);
Xrm.Page.getControl("advis_lastclosedatechange").setDisabled(true);
Xrm.Page.getControl("advis_estvaluechange").setDisabled(true);
Xrm.Page.getControl("advis_lastestvaluechange").setDisabled(true);
// Hiding Fields
Xrm.Page.getAttribute("stepname_c").innerText = "";
Xrm.Page.getControl("stepname").setVisible(none);
}
function advis_projectid_onchange()
{
}
function salesstagecode_onchange()
{
// Get the field that fired the event.
var oSalesStage = event.srcElement;
var oProbability = Xrm.Page.getAttribute("closeprobability");
var oEstValue = Xrm.Page.getAttribute("estimatedvalue");
var oWeightedValue = Xrm.Page.getAttribute("advis_weightedvalue");
Xrm.Page.getAttribute("stepname").setValue(oSalesStage.getSelectedOption().text);
// Validate the field information.
if (typeof(oProbability) != "undefined" && oProbability != null)
switch (oSalesStage.getValue())
{
case "200000":
{
oProbability.setValue(0);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
break;
}
case "200001":
{
oProbability.setValue(20);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue() *oEstValue.getValue()/100);
break;
}
case "200002":
{
oProbability.setValue(50);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
break;
}
case "200003":
{
oProbability.setValue(50);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
break;
}
case "200004":
{
oProbability.setValue(75);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
break;
}
case "200005":
{
oProbability.setValue(90);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
break;
}
case "200006":
{
oProbability.setValue(100);
if (typeof(oEstValue ) != "undefined" && oEstValue != null)
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
break;
}
}
}
function isrevenuesystemcalculated_onchange()
{
}
function estimatedvalue_onchange()
{
// Get the field that fired the event.
var oEstValue = event.srcElement;
var oProbability = Xrm.Page.getAttribute("closeprobability");
var oWeightedValue = Xrm.Page.getAttribute("advis_weightedvalue");
var oChange = Xrm.Page.getAttribute("advis_estvaluechange");
var oLastChange = Xrm.Page.getAttribute("advis_lastestvaluechange");
var today = new Date();
// Validate the field information.
if (typeof(oEstValue) != "undefined" && oEstValue != null)
{
if (typeof(oProbability) != "undefined" && oProbability != null)
{
oWeightedValue.setValue(oProbability.getValue()*oEstValue.getValue()/100);
}
if (typeof(oChange) != "undefined" && oChange != null)
{
oLastChange.setValue(oChange.getValue());
oChange.setValue(today);
}
else
{
oChange.setValue(today);
}
}
}
function estimatedclosedate_onchange()
{
var oEstCloseDate = event.srcElement;
var oChange = Xrm.Page.getAttribute("advis_closedatechange");
var oLastChange = Xrm.Page.getAttribute("advis_lastclosedatechange");
var today = new Date();
// Validate the field information.
if (typeof(oEstCloseDate) != "undefined" && oEstCloseDate != null)
{
if (typeof(oChange) != "undefined" && oChange != null)
{
oLastChange.setValue(oChange.getValue());
oChange.setValue(today);
}
else
{
oChange.setValue(today);
}
}
}
10. Februar 2016 09:39
10. Februar 2016 10:55