我写了这一共同功能,基本上以某种形式掩饰属性,并将其带入自己......
/*
Opens a new window, copying the current page, and loading the new item with the current values
* Sample call *
var url = "main.aspx?etn=task&pagetype=entityrecord";
var features = location=no,status=yes,scrollbars=no,menubar=no,toolbar=no,width=900,height=600 ;
CommonLib.openClone(url, _blank , features, Xrm.Page.getAttribute(null));
*/
openClone: function (url, windowName, features, attributes) {
var qsParams = "";
var qs;
for (var i = 0; i < attributes.length; i++) {
qs = CommonLib.getExtraQS(attributes[i]);
if (qs.length > 0) {
qsParams += qs + "&";
}
} //end for
// Remove extra &
qsParams = qsParams.substring(0, qsParams.length - 1);
window.open("/" + Xrm.Page.context.getOrgUniqueName() + "/" + url + "&extraqs=" + encodeURIComponent(qsParams), windowName, features, false);
},
/*
returns the extraqs value for the attribute, non-encodURIComponent-ed
*/
getExtraQS: function (attribute) {
var extraQS = "";
if (attribute != null && attribute.getValue() != null) {
// Set name value based on type and id
switch (attribute.getAttributeType()) {
case "lookup":
var value = attribute.getValue();
var name = attribute.getName();
if (value != null && value.length > 0) {
value = value[0];
extraQS = name + "=" + value.id + "&" + name + "name=" + value.name;
switch(value.typename){
case account :
case contact :
case systemuser :
case team :
extraQS += "&" + name + "type=" + value.typename;
break;
}
}
break;
case "datetime":
extraQS = attribute.getName() + "=" + CommonLib.getCRMDateFormat(attribute.getValue());
break;
default:
extraQS = attribute.getName() + "=" + attribute.getValue();
break;
}
}
return extraQS;
}
除非我试图通过“<代码> 账户>/代码”的属性,否则所有作品都将受到罚款。 我获得标准“错误”。 发生错误...... 如果我跳过第二次开关发言,那么我就拿不到一份CRM。 不管怎样的错误,但CRM会冒着企图使物体脱轨的错误,因为它有一套类型,造成错误。
如何做到这一点的想法?
Edit: 转而使用CRM服务器的伐木结果就属于这一例外情形,该例外列出了作为无效参数的异构型,尽管它准确描述了SDK所说的使用方式(http://msdn.microsoft.com/en-us/library/gg334375.aspx),如果我通过除这一参数外一切,在CRM javascript中,我只获得一个 j语,因为这种名称是无效的。
[2011-11-04 08:27:53.961] Process: w3wp |Organization:306a6cd8-f599-df11-b324-005056bb527b |Thread: 14 |Category: Application |User: 00000000-0000-0000-0000-000000000000 |Level: Error | ErrorInformation.LogError
at ErrorInformation.LogError()
at ErrorInformation..ctor(Exception exception, Uri requestUrl, Boolean logError)
at MainApplication.Application_Error(Object sender, EventArgs eventArguments)
at EventHandler.Invoke(Object sender, EventArgs e)
at HttpApplication.RaiseOnError()
at ApplicationStepManager.ResumeSteps(Exception error)
at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
>MSCRM Error Report:
--------------------------------------------------------------------------------------------------------
Error: Exception of type System.Web.HttpUnhandledException was thrown.
Error Message: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Error Details: Exception of type System.Web.HttpUnhandledException was thrown.
Source File: Not available
Line Number: Not available
Request URL: http://dev-crmapp03.abc.com/TestOrg/userdefined/edit.aspx?actualdurationminutes=1&etc=4212&abc_category=9&abc_contactmade=false&abc_pointofcontactid=%7b7E599729-1923-E011-858E-005056BB527B%7d&abc_pointofcontactidname=Human%20Resources&abc_result=11&ownerid=%7bCAA79C99-0E9C-DF11-9D85-005056BB728E%7d&owneridname=Rachel%20Richardson&owneridtype=systemuser&pagemode=iframe®ardingobjectid=%7b58949706-1923-E011-858E-005056BB527B%7d®ardingobjectidname=Cold%20Emails%20-%20016®ardingobjectidtype=account&sitemappath=Workplace%7cMyWork%7cnav_dashboards&subject=%2a%20Security%20Alarm%20Installer%20%2f%20Technician%20%2a%20%28St.Louis%29
Stack Trace Info: [InvalidOperationException: CRM Parameter Filter - Invalid parameter regardingobjectidtype=account in Request.QueryString on page /TestOrg/userdefined/edit.aspx
The raw request was GET /TestOrg/userdefined/edit.aspx?actualdurationminutes=1&etc=4212&abc_category=9&abc_contactmade=false&abc_pointofcontactid=%7b7E599729-1923-E011-858E-005056BB527B%7d&abc_pointofcontactidname=Human%20Resources&abc_result=11&ownerid=%7bCAA79C99-0E9C-DF11-9D85-005056BB728E%7d&owneridname=Rachel%20Richardson&owneridtype=systemuser&pagemode=iframe®ardingobjectid=%7b58949706-1923-E011-858E-005056BB527B%7d®ardingobjectidname=Cold%20Emails%20-%20016®ardingobjectidtype=account&sitemappath=Workplace%7cMyWork%7cnav_dashboards&subject=%2a%20Security%20Alarm%20Installer%20%2f%20Technician%20%2a%20%28St.Louis%29 called from http://dev-crmapp03.abc.com/TestOrg/main.aspx?etn=task&pagetype=entityrecord&extraqs=subject%3D*%20Security%20Alarm%20Installer%20%2F%20Technician%20*%20(St.Louis)%26abc_category%3D9%26regardingobjectid%3D%7B58949706-1923-E011-858E-005056BB527B%7D%26regardingobjectidname%3DCold%20Emails%20-%20016%26regardingobjectidtype%3Daccount%26abc_pointofcontactid%3D%7B7E599729-1923-E011-858E-005056BB527B%7D%26abc_pointofcontactidname%3DHuman%20Resources%26ownerid%3D%7BCAA79C99-0E9C-DF11-9D85-005056BB728E%7D%26owneridname%3DRachel%20Richardson%26owneridtype%3Dsystemuser%26abc_contactmade%3Dfalse%26abc_result%3D11%26actualdurationminutes%3D1.]
at Microsoft.Crm.Application.ParameterFilter.ValidateParameter(HttpRequest request, ArrayList parameterCollection, String key, String value, ParameterSources source, EntityType pageEntityType, FormAdditionalAllowedParameters additionalAllowedParameters)
at Microsoft.Crm.Application.ParameterFilter.ValidateParameters(Page page, EntityType pageEntityType, Boolean alwaysEnableParameterChecking, FormAdditionalAllowedParameters formAdditionalAllowedParametersTemp)
at Microsoft.Crm.Application.ParameterFilter.ValidateParameters(Page page, EntityType pageEntityType, FormAdditionalAllowedParameters formAdditionalAllowedParametersTemp)
at Microsoft.Crm.Application.Controls.AppPage.ValidatePageParameters()
at Microsoft.Crm.Application.Controls.PageManager.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)