Hello Everyone,
I have a custom code to close an incedent. that is running, when we press one custom botton in the form Case...
with the version V8.2 works properly but with the V9.0 I have the below error. I am ussing the Api to do that. and of course I updated the API number version.
and when I run the botton the below error appeared.
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext, Dictionary`2 optionalParameters)
↵ at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Execute(OrganizationRequest request, ExecutionContext executionContext)
↵ at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.ExecuteOperation(CrmODataExecutionContext context, EdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters)
↵ at Microsoft.Crm.Extensibility.OData.ActionController.ProcessOperationRequest(String operationName, Dictionary`2 operationParameters, EntityReference entityReference, String boundEntityName, String boundEntityType)
↵ at Microsoft.Crm.Extensibility.OData.ActionController.<>c__DisplayClass9_0.<PostUnboundAction>b__0()
↵ at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
↵ at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)
↵ at lambda_method(Closure , Object , Object[] )
↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
↵ at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
↵--- End of stack trace from previous location where exception was thrown ---
↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
↵ at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
↵ at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
---------------------------------------------------------------------------------------------------------------------------------
This is a copy of the javascripto code.
*This post is locked for comments
I found this and it was super helpful. Cleared almost all my errors identified by the Dynamics JavaScript Validator.
I just have a few errors left.
Method openEntityForm must be replace with Xrm.Navigation.openForm
And it looks like this might be useful
I found the error in my code.
I used this:
"incidentid@odata.bind": "/incidents/(" + incidentid + ")",
I should have used this:
"incidentid@odata.bind": "/incidents(" + incidentid + ")",
I tested the following function in both v8.2 and v9.0. It worked for both
var ns = { resolveIncident: function (subject, incidentid, timespent, description) { var incidentResolution = { "subject": subject, "incidentid@odata.bind": "/incidents(" + incidentid + ")", "timespent": timespent, "description": description }; var parameters = { "IncidentResolution": incidentResolution, "Status": 5 }; var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/CloseIncident", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 204) { console.log("Successfully resolved incident") } else { console.log(JSON.parse(this.response).error.message) } } }; req.send(JSON.stringify(parameters)); } }; ns.resolveIncident("Close Case", "A44ECC5C-8BAB-E611-80F5-3863BB2E03E0", 60, "Additional Description here");
Hello Jim
yes, I added code to see the error, but the error messages it is not suitable to resolve something..
I dont really know what could be the issue, I opened a tickect to Microsoft to follow up, once I have something I will put it here in the post.
{"error":{"code":"0x80040265","message":"OrganizationServiceFault","innererror":{"message":"OrganizationServiceFault","type":"System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]","stacktrace":" at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext, Dictionary`2 optionalParameters)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Execute(OrganizationRequest request, ExecutionContext executionContext)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.ExecuteOperation(CrmODataExecutionContext context, EdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.ProcessOperationRequest(String operationName, Dictionary`2 operationParameters, EntityReference entityReference, String boundEntityName, String boundEntityType)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.<>c__DisplayClass9_0.<PostUnboundAction>b__0()\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}}}
You have provided the stack trace, but I don't see the simple error I expect.
If you replace:
var errorText = this.responseText
with this:
var errorText =JSON.parse(this.response).error.message
I think you will get something more meaningful than the stacktrace you are seeing.
If you get 'Empty segment encountered in request URL. Please make sure that a valid request URL is specified.' - then you are getting the same thing I'm getting and it might be a bug.
This is a function I wrote to test this:
var ns = { resolveIncident: function (subject, incidentid, timespent, description) { var incidentResolution = { "subject": subject, "incidentid@odata.bind": "/incidents/(" + incidentid + ")", "timespent": timespent, "description": description }; var parameters = { "IncidentResolution": incidentResolution, "Status": 5 //Problem solved }; var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/CloseIncident", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 204) { console.log("Successfully resolved incident") } else { console.log(JSON.parse(this.response).error.message) } } }; req.send(JSON.stringify(parameters)); } };
This is how you call it:
ns.resolveIncident("Close Case", "a44ecc5c-8bab-e611-80f5-3863bb2e03e0", 60, "Additional Description here");
It is late and I am tired, so I might have made some error.
.
Hello Adrian
Thank you so much for your help, but the issue is not releated with the deprecated things in Vs9.0 as Microsoft mentioned, “Deprecated” means we intend to remove the feature or capability from a future major release of Dynamics 365. so the XRM.Page should be work in this version... and yes, the tool just mention
----Line number 22: Method Xrm.Page must be replace with ExecutionContext.getFormContext
----Line number 22: Method Xrm.Page.context must be replace with Xrm.Utility.getGlobalContext
Hi Miguel,
The problem is posible in the use Xrm.Page.Context, in the new version is used Xrm.Utility.getGlobalContext, in the new version is present changes in the actions from javascript, in the link describe the deprecated client API in javascript and the replace code.
docs.microsoft.com/.../important-changes-coming
Regards...
Hi Miguel Laines,
Run your JavaScript code through the Dynamics 365 V9 Javascript Validator in the XrmToolBox.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156