I keep getting this error when I create a custom view using javascript, and save it.
-
08 Mayıs 2012 Salı 20:37
I keep getting this error
Error Description: 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. Full Stack: [FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).] at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException) at System.Guid.TryParseGuidWithDashes(String guidString, GuidResult& result) at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result) at System.Guid..ctor(String g) at Microsoft.Crm.Application.Platform.AttributeCollection.CreateEnityReferenceFromLookupPropertyValue(String name, Object value, IOrganizationContext context) at Microsoft.Crm.Application.Platform.AttributeCollection.SetEntityProperty(Entity entity, String name, String childAttributeName, Object parentProperty, AttributeMetadata attributeMetadata, Object value, IOrganizationContext context) at Microsoft.Crm.Application.Platform.AttributeCollection.Insert(String name, Object value, Boolean throwIfKeyExists) at Microsoft.Crm.Application.Platform.EntityProxy.SetLookupValueData(XmlNode node) at Microsoft.Crm.Application.Platform.EntityProxy.SetData(XmlNode entityElement) at Microsoft.Crm.Application.Forms.EndUserForm.RetrieveParametersForEventDefault() at Microsoft.Crm.Application.Forms.EndUserForm.Initialize(Entity entity) at Microsoft.Crm.Application.Forms.CustomizableForm.Execute(Entity entity, FormDescriptor fd) at Microsoft.Crm.Application.Components.Utility.GenericEventProcessor.RaiseEvent(String eventName) 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) [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.] at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I copied everything, this only happends when my javascript runs and I select a record using the view that I created with javascript, even after I the javascript runs I can select another view one of the default ones and it works perfectly when I save it.
So I mean what is going on? I've tried almost everything using a new GUID generating one, or what I have no idea what is going on and I"m really annoyed at this... WTF?!Here is my code...
function GetInstitutionFromSession(lookupField, entityName, entityAttribute){ // prompt("Test",Xrm.Page.context.getUserId()); try{ var recordId = Xrm.Page.getAttribute(lookupField).getValue(); if(recordId != null){ var recordGUID = recordId[0].id; var oDataSelect = Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/" + entityName + "Set?select=*&$filter=" + entityName + "Id eq guid'" + recordGUID + "'"; //prompt("My oDataSelect: ", oDataSelect); var retrieveRecord = new XMLHttpRequest(); retrieveRecord.open('GET', oDataSelect, false); retrieveRecord.setRequestHeader("Accept", "application/json"); retrieveRecord.setRequestHeader("Content-Type", "application/json; charset=utf-8"); retrieveRecord.send(null); var record = JSON.parse(retrieveRecord.responseText); //if(!(jQuery.isEmptyObject( record.d.results[0] ))) //{ var results = record.d.results[0]; //This gets the GUID of the selected field var GUID=results[entityAttribute]["Id"] //This gets the Name (primary ID) of the entiy. var Name=results[entityAttribute]["Name"] ChangeLookupView_StateStudents(GUID,Name); // } } else{ } } catch(e){ alert('An error has occurred: ' + e.message) } } //'xrmsm_educationalstructurelookup', 'xrmsm_educationalstructure', 'xrmsm_InstitutionLookup', 'xrmsm_institutionlookup' function ChangeLookupView_StateStudents(GUID,Name) { //alert(" ChangeLookup Finally RAN!!!!!!"); //Set parameters values needed for the creation of a new lookup view... //var viewId = Xrm.Page.data.entity.getId(); // Your new lookup views needs a unique id. It must be a GUID. Here I use the GUID of the current record. var viewId= "{83506A2C-D616-474c-88BD-626816616CBC}"//Xrm.Page.context.getUserId(); var entityName = "xrmsm_students"; // The entity your new lookup view relates to var viewDisplayName = " Student by Institutions View"; // A name for new lookup view var viewIsDefault = true; // Whether your new lookup view should be the default view displayed in the lookup or not //Define the Fetch XML query your new lookup view will use. You can create this via Advanced Find. You'll need to massage the syntax a little though //prompt("awesome",institutionName); //alert( "<condition attribute='xrmsm_students_id' value='%"+institutionName+"%' operator='like'/>") var fetchXml = " <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+ "<entity name='xrmsm_students'>"+ "<attribute name='xrmsm_students_id' />"+ "<attribute name='xrmsm_studentsreferalstatus' />"+ "<attribute name='xrmsm_studentsmiddlename' />"+ "<attribute name='xrmsm_studentsmedicalinformation' />"+ "<attribute name='xrmsm_studentslastname' />"+ "<attribute name='xrmsm_studentsgrade' />"+ "<attribute name='xrmsm_studentsgender' />"+ "<attribute name='xrmsm_studentsfirstname' />"+ "<attribute name='xrmsm_studentsemail' />"+ "<attribute name='xrmsm_studentsdateofbirth' />"+ "<attribute name='xrmsm_studentsid' />"+ "<order attribute='xrmsm_students_id' descending='false' />"+ "<filter type='and'>"+ //" <condition attribute='xrmsm_studentsgender' operator='eq' value='199510001' />"+ //"<condition attribute='xrmsm_students_id' value='%536%' operator='like'/>"+ "<condition attribute='xrmsm_students_id' value='"+Name+"%' operator='like'/>"+ " </filter>"+ " </entity>"+ "</fetch>"; //alert(fetchXml); //Define the appearance of your new lookup view var layoutXml = "<grid name='resultset' object='1' jump='xrmsm_students_id' select='1' icon='1' preview='1'>" + "<row name='result' id='xrmsm_students_id'>" + // id = the GUID field from your view that the lookup should return to the CRM form "<cell name='xrmsm_students_id' width='100' />" + "<cell name='xrmsm_studentsfirstname' width='100' />" + "<cell name='xrmsm_studentslastname' width='100' />" + "<cell name='xrmsm_studentsmiddlename' width='100' />" + "<cell name='xrmsm_studentsdateofbirth' width='100' />" + "<cell name='xrmsm_studentsgender' width='100' />" + "<cell name='xrmsm_studentsgrade' width='100' />" + "<cell name='xrmsm_studentsemail' width='100' />" + "<cell name='xrmsm_studentsmedicalinformation' width='100' />" + "<cell name='xrmsm_studentsreferalstatus' width='100' />" + "</row>" + "</grid>"; //alert(layoutXml); //Add your new view to the Lookup's set of availabe views and make it the default view Xrm.Page.getControl("xrmsm_studentlookup").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, viewIsDefault); }
Tüm Yanıtlar
-
09 Mayıs 2012 Çarşamba 16:24Anyone?
-
09 Mayıs 2012 Çarşamba 20:51
The problem is coming from this line
"<condition attribute='xrmsm_students_id' value='"+Name+"%' operator='like'/>"+
Instead of using the Name field, you should be using the Guid value.
Hope this helps.
Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits
- Yanıt Olarak Öneren Dimaz Pramudya (www.xrmbits.com) 09 Mayıs 2012 Çarşamba 20:51
- Yanıt Önerisini Geri Alan rroman90 10 Mayıs 2012 Perşembe 12:13
-
10 Mayıs 2012 Perşembe 12:13Yeah well the GUID value doesn't help either I changed the filter to this
"<condition attribute='xrmsm_studentsid' value='{38EF1FFF-129A-E111-ACFB-00155D640B07}' uitype='xrmsm_students' uiname='536-12-0006' operator='eq'/>
just to test it out.... but when I select what was filtered using the view I GET A BIG FAT ERROR..... So terrible frustrated. Any other tips or ideas people? I've tried everything.... I'm truly at my wits end.... -
10 Mayıs 2012 Perşembe 13:51
I found out my problem, in my layoutXML I was using the wrong id in the following line.
"<row name='result' id='xrmsm_sessionsid'>"
I was using
"<row name='result' id='xrmsm_sessions_id'>"
That was the whole problem.... -_-
- Yanıt Olarak İşaretleyen rroman90 10 Mayıs 2012 Perşembe 13:51