onload事件正在触发,我没有得到任何错误,但计算字段不刷新? 它应该从函数FWeightedValue()进行计算。
以下是代码,我们将不胜感激。
frmOnLoad();
onLoad = false;
}
catch(e)
{ alert(e.message); }
}//End of if condition
}//End of function
/* Declare Variables */
var onLoad = true;
var sGlobalVar = '';
function frmOnLoad()
{ ResizeScreen();
AddLogoToFormTitle(160, "/CRM4Legal/_imgs/reznick_small.gif");
fldMerge('name');
fldMerge('customerid');
fldMerge('rg_officeid');
fldStatus();
fldGSMC();
FWeightedValue();
frmTabs();
frmNav();
frmIFrames();
if ($("rg_gsmc" ) != null) $("rg_gsmc" ).onclick = fldGSMC;
}
function FWeightedValue()
{ with ( crmForm.all )
var EstRev = crmForm.getAttribute("estimatedvalue").getValue();
var RiskWeight = Xrm.Page.getAttribute("cpdc_riskweight").getValue();
var RiskPercent = RiskWeight / 100;
Xrm.Page.data.entity.attributes.get("cpdc_riskweightedvalue").setValue(RiskWeightValue);
sectionDisplay( true, cpdc_riskweightedvalue);
}
FWeightedValue.NullCheck = function (value)
{
if (value == null) {
return 0.0;
} else {
return value;
}
}
}
function fldStatus()
{ with ( crmForm.all )
{ if ( statuscode.SelectedText == 'Won' || statuscode.SelectedText == 'Lost' )
{ crmForm.SetFieldReqLevel("rg_winlossreason", 1);
sectionDisplay( false, rg_winlossreason );
}
else
{ crmForm.SetFieldReqLevel("rg_winlossreason", 0);
rg_winlossreason.DataValue = null;
sectionDisplay( true, rg_winlossreason );
}
}
}
function fldGSMC()
{ with ( crmForm.all )
{ sectionDisplay( !rg_gsmc.DataValue, rg_contractnumber );
crmForm.SetFieldReqLevel("rg_contracttype", ( rg_gsmc.DataValue ? 1 : 0 ));
}
}
function fldMerge(fld)
{ if ( fld == null ) { return; }
var cell = $(fld + '_d');
if ( cell == null ) { return; }
var row = cell.parentNode;
if ( row == null ) { return; }
cell.colSpan = 3;
row.removeChild(cell.nextSibling);
row.removeChild(cell.nextSibling);
}
function frmTabs()
{ tab('Hidden', 'hidden');
}
function frmNav()
{ navHide ('nav_rg_opportunity_rg_opportunitypracticearea');
navHide ('nav_rg_opportunity_rg_opportunityservicearea');
navHide ('nav_rg_opportunity_rg_engagementteam');
navHide ('nav_rg_opportunity_rg_opportunityteam');
navHide ('navProducts');
navHide ('navQuotes');
navHide ('navOrders');
navHide ('navInvoices');
navHide ('navComp');
navHide ('_NA_SFA');}
function frmIFrames()
{ /* Engagement Team */
var n2nPA = new N2NViewer('IFRAME_EngagementTeam');
/* Set the role order - use iedevtoolber for exact parameters */
n2nPA.RoleOrder = 1;
/* assing the relationship name (without the "area" word) */
n2nPA.TabsetId = "rg_opportunity_rg_engagementteam";
n2nPA.Load();
/* Opportunity Team */
var n2nPA = new N2NViewer('IFRAME_OpportunityTeam');
n2nPA.RoleOrder = 1;
n2nPA.TabsetId = "rg_opportunity_rg_opportunityteam";
n2nPA.Load();
/* Practice Areas */
var n2nPA = new N2NViewer('IFRAME_PracticeAreas');
n2nPA.RoleOrder = 1;
n2nPA.TabsetId = "rg_opportunity_rg_opportunitypracticearea";
n2nPA.Load();
/* Service Areas */
var n2nService = new N2NViewer('IFRAME_Services');
n2nService.RoleOrder = 1;
n2nService.TabsetId = "rg_opportunity_rg_opportunityservicearea";
n2nService.Load();
}
function $(name)
{ return document.getElementById(name);
}
function navHide (name)
{ if ($(name) != null) { $(name).style.display = "none"; }
}
function tab ( tabName, tabVisibility )
{ tabVisibility = ( tabVisibility == "visible" ? "" : "none" );
var _tabs = crmForm.getElementsByTagName("li");
for (var i = 0; i < _tabs.length; i++)
{ var _tab = _tabs[i];
if ( _tab.innerText == tabName )
{ _tab.style.display = tabVisibility;
break;
}
}
}
function sectionDisplay(vis, sec)
{ sec.parentElement.parentElement.parentElement.style.display = ((vis) ? 'none' : 'block');
}
function ResizeScreen()
{ var aH = screen.availHeight;
var aW = screen.availWidth;
var top = 0;
var left = 0;
if ( aW >= 1124 && aH >= 800)
{ var aH = (aH > 800 ? 800 : 768);
var aW = 1124;
var top = (screen.availHeight - aH) / 2;
var left = (screen.availWidth - aW) / 2;
}
// aH = (crmForm.FormType == frmType.Create ? 295 : aH);
window.moveTo(left, top);
window.resizeTo(aW, aH);
}
function N2NViewer(iframeId)
{ if (!document.all[iframeId])
{ alert(iframeId + " is missing!");
return;
}
var viewer = this;
var _locAssocObj = null;
viewer.IFRAME = document.all[iframeId];
viewer.RoleOrder;
viewer.TabsetId;
viewer.Load = function()
{ if (crmForm.ObjectId != null)
{ /* Construct a valid N2N IFRAME url */
viewer.IFRAME.src = "areas.aspx?oId=" + crmForm.ObjectId + "&oType=" + crmForm.ObjectTypeCode + "&security=" + crmFormSubmit.crmFormSubmitSecurity.value + "&roleOrd=" + viewer.RoleOrder + "&tabSet=" + viewer.TabsetId;
viewer.IFRAME.onreadystatechange = viewer.StateChanged;
}
else
{ viewer.IFRAME.src = "about:blank";
}
}
viewer.StateChanged = function()
{ if (viewer.IFRAME.readyState != 'complete')
{ return;
}
var iframeDoc = viewer.IFRAME.contentWindow.document;
/* Reomve scrolling space */
iframeDoc.body.scroll = "no";
/* Remove crmGrid Default padding */
iframeDoc.body.childNodes[0].rows[0].cells[0].style.padding = 0;
/* Save MS locAssocObj */
_locAssocObj = locAssocObj;
/* Override MS locAssocObj */
locAssocObj = viewer.locAssocObj;
}
viewer.locAssocObj = function(iType , sSubType, sAssociationName, iRoleOrdinal)
{ /* Open the Dialog */
_locAssocObj(iType , sSubType, sAssociationName, iRoleOrdinal);
/* Refresh only if our iframe contains the correnct tabset name */
if (sAssociationName == viewer.TabsetId)
{ viewer.IFRAME.contentWindow.document.all.crmGrid.Refresh();
}
}
}
function AddLogoToFormTitle(logoWidth, logoUrl)
{ var formTitleTable = null;
var tables = document.getElementsByTagName("table");
for(var i = 0; i < tables.length; i++)
{ var className = tables[i].className;
if (className && className.indexOf("ms-crm-Form-Title") == 0)
{ formTitleTable = tables[i];
break;
}
}
if (formTitleTable)
{ var newCell = formTitleTable.rows[0].insertCell(2);
newCell.width = logoWidth;
newCell.vAlign = "middle";
newCell.innerHTML = '<img src="'+logoUrl+'" border="0" align="right" />';
}
}
function UnUsed()
{
if(false)
{
try
{
答案 0 :(得分:0)
您混合使用CRM 4.0和CRM 2011 SDK。难怪没有什么工作! 如果您的目标平台是CRM 4.0,则应该编写以下内容
function FWeightedValue()
{
var EstRev = crmForm.estimatedvalue.DataValue;
var RiskWeight = crmForm.cpdc_riskweight.DataValue;
var RiskPercent = RiskWeight / 100;
crmForm.cpdc_riskweightedvalue.DataValue = RiskWeightValue;
// second parameter is sec ??? or field
sectionDisplay( true, crmForm.cpdc_riskweightedvalue);
}
答案 1 :(得分:0)
您是否尝试过强制提交?
Xrm.Page.getAttribute(fieldName).setSubmitMode("always");