Skip to main content

Posts

Showing posts with the label D365

Resource not found for the segment

  Using D365 Flow if you want to insert or update a record then you may get this error. This error was raised because in your entity this is a lookup field and you need to set the value with the lookup entity plural name. Like

D365 Add search criteria field into lookup field.

 If you want to add a search field into the lookup view you will not able to add the add option.  In this case, you need to add the field into Quick Find View it will take the impact of another view For my case, I was using Product Lookup view into lookup view 

D365 Error converting attribute value to Property

 You are getting this error into your plugin  Unable to cast object of type 'System.Guid' to type 'Microsoft.Xrm.Sdk.EntityReference' Your crud operation Entity field has a Lookup field relationship and it is expecting EntityReference. EntityReference conactEntityReference = new EntityReference { Id = newContactEntity.Id, LogicalName = Contact.EntityLogicalName }; localContext.OrganizationService.Update(new Entity(proevt_eventregistration.EntityLogicalName, inputEventseriesEntity.Id) { ["proevt_contactid"] = conactEntityReference });  

D365 get fetchxml alias value

 If we use an alias in our fetchxml query it will not retrieve the alias attribute like the default query. String inputstdssAttendeeFetchXML = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='std_stdssattendee' > <attribute name='std_attendeeroleid' /> <filter> <condition attribute='std_stdstdssid' operator='eq' value='{ inputstdss.GetAttributeValue<Guid>("std_stdstdssid")}' /> <condition attribute='statecode' operator='eq' value='0' /> <condition attribute='std_attendeeroleid' operator='not-null' /> ...

D365 call another action from plugin

 If we want to call another plugin or action from plugin we can use this approach. // Call std Copy action into plugin OrganizationRequest request = new OrganizationRequest("std_Copystd"); request["Target"] = stdEntityReference; OrganizationResponse response = localContext.OrganizationService.Execute(request); string clonestdresultresult = (string)response.Results["Result"]; string ClonestdId = (string)response.Results["CloneId"];

D365 update entity without retrive entity into plugin

 we can update any entity record without retrieving  String stdattendeeFetchXML = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='std_stdattendee' > <attribute name='std_contactid' /> <attribute name='std_attendeecategory' /> <attribute name='std_attendeeroleid' /> <attribute name='std_name' /> <filter type='and' > <condition attribute='std_stdid' operator='eq' value='{ClonestdId}' /> <condition attribute='statecode' operator='eq' value='0' /> ...

D365 grid selected row id into javascript

 If you want to get all selected values of a subgrid you can try with this sample. var gridContext = formContext.getControl("AttendeesSubgrid"); var allSelectedRows = gridContext.getGrid().getSelectedRows(); var attendeeList = []; allSelectedRows.forEach(GetSelectedRecord); function GetSelectedRecord(item) { var rowData = item._entityId; var attendiee = rowData.guid; attendeeList.push(attendiee); }

D365 lookup Custom filtering javascript

 In my case, I need to add custom filtering when I select a lookup it will populate another lookup. when the user will click on the search icon it will show only filter data.  I was following:  https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/controls/addpresearch sample code: var demoLAB = demoLAB || {}; var classId; demoLAB.Stuedent = { Form: { Load: function (executionContext) { 'use strict'; var formContext = executionContext.getFormContext(); this.attachEvents(executionContext); }, attachEvents: function (executionContext) { 'use strict'; var formContext = executionContext.getFormContext(); var form = demoLAB.Stuedent.Form; // Student Change Event formContext.getAttribute("demo_studentId").addOnChange(form.studentOnChange); }, studentOnChange: function (executionContext) { ...

D365 FetchXML query into plugin

 Generate the xml query using xrmtoolbox and try with this code sample. String eventsessionFetchXML = $@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='baseevt_eventsession' > <attribute name='baseevt_eventid' /> <attribute name='baseevt_sessionenddatetime' /> <attribute name='baseevt_sessionstartdatetime' /> <attribute name='baseevt_name' /> <attribute name='baseevt_description' /> <filter> <condition attribute='baseevt_eventid' operator='eq' value='{inputEntity.Id.ToString()}' /> </filter> </entity> </fetch>"; var eventSessionresult =...

D365 Custom Action call from ribbon button javascript event

  If you want to call plugin from ribbon button click event with custom action, you can use this script. // Ribbon button click event call custom action executeCloneEvent: function (formContext, eventId) { var eventId = formContext.data.entity.getId(); var entityrecordId = eventId.substr(1, eventId.length - 2); var request = { entity: { entityType: "account", id: entityrecordId}, getMetadata: function () { return { boundParameter: "entity", parameterTypes: { "entity": { "typeName": "account", "structuralProperty": 5 }, }, operationType: 0, operationName: "acct_CloneEvent" }; } }; // Calling Plugin Xrm.WebApi.online.execute(request).then(function (result) { ...