Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

error on service activity creation wit xrm.webapi.createrecord

Posted on by 22

trying to create a service activity from a button. I'm System admin so i have all the rigth needed. 

here is my code for the service activity parts:


mdf.createProject.createServiceActivities = function (projectGuid, serviceActivities) {
var sa = {
"serviceid@odata.bind" : "/services(01d2bb06-6cf9-ed11-8f6d-000d3ae86452)",
"subject" : serviceActivities.subject,
"regardingobjectid_incident@odata.bind" : "/incidents("   projectGuid   ")",
"statecode" : "0"
};

return new Promise(function (resolve, reject) {
Xrm.WebApi.createRecord("serviceappointment", sa).then(
function success(result){
console.log(result);
Xrm.Utility.closeProgressIndicator();
Xrm.Page.getControl('Project').refresh();
resolve(console.log("ENFIN!"))
},
function(error){
Xrm.Utility.closeProgressIndicator();
reject(console.log(error))
}
);
});

}

And the error i get:

  1. code: 2147746327
  2. errorCode: 2147746327
  3. message: "The requested record was not found or you do not have sufficient permissions to view it."
  4. raw: "{\"errorCode\":2147746327,\"message\":\"The requested record was not found or you do not have sufficient permissions to view it.\",\"code\":2147746327,\"title\":\"Record Is Unavailable\",\"raw\":\"{\\\"_errorCode\\\":2147746327,\\\"_errorFault\\\":{\\\"_responseXml\\\":null,\\\"_errorCode\\\":2147746327,\\\"_innerFault\\\":{\\\"_responseXml\\\":null,\\\"_errorCode\\\":0,\\\"_innerFault\\\":null,\\\"_callStack\\\":null,\\\"_responseText\\\":null,\\\"_annotations\\\":null,\\\"_hasCustomerInfo\\\":false,\\\"_messages\\\":[\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\"},\\\"_callStack\\\":null,\\\"_responseText\\\":\\\"{\\\\\\\"error\\\\\\\":{\\\\\\\"code\\\\\\\":\\\\\\\"0x80040217\\\\\\\",\\\\\\\"message\\\\\\\":\\\\\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\\\\\",\\\\\\\"@Microsoft.PowerApps.CDS.HelpLink\\\\\\\":\\\\\\\""@Microsoft.PowerApps.CDS.TraceText\\\\\\\":\\\\\\\"[Microsoft.Dynamics.Service.Plugins:">go.microsoft.com/.../ Microsoft.Dynamics.Service.Plugins.PreOperationServiceAppointmentCreate\\\\\\\\r\\\\\\\\n[3f95a566-54ff-e611-80e7-00155db32b08: Create of serviceappointment\\\\\\\\r\\\\\\\\nEntered Microsoft.Dynamics.Service.Plugins.PreOperationServiceAppointmentCreate.Execute(), Correlation Id: 73633c68-18ca-4296-8b90-16ed7f254cb1, Initiating User: fe68f04b-3f9c-ed11-aad1-0022483c8531\\\\\\\\r\\\\\\\\nException: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist (Fault Detail is equal to Exception details: \\\\\\\\r\\\\\\\\nErrorCode: 0x80040217\\\\\\\\r\\\\\\\\nMessage: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\\\\\\r\\\\\\\\nTimeStamp: 2023-06-01T16:25:08.1774955Z\\\\\\\\r\\\\\\\\n--\\\\\\\\r\\\\\\\\nException details: \\\\\\\\r\\\\\\\\nErrorCode: 0x80040217\\\\\\\\r\\\\\\\\nMessage: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\\\\\\r\\\\\\\\nTimeStamp: 2023-06-01T16:25:08.1774955Z\\\\\\\\r\\\\\\\\n--\\\\\\\\r\\\\\\\\n)., Correlation Id: 73633c68-18ca-4296-8b90-16ed7f254cb1, Initiating User: fe68f04b-3f9c-ed11-aad1-0022483c8531\\\\\\\\r\\\\\\\\nExiting Microsoft.Dynamics.Service.Plugins.PreOperationServiceAppointmentCreate.Execute(), Correlation Id: 73633c68-18ca-4296-8b90-16ed7f254cb1, Initiating User: fe68f04b-3f9c-ed11-aad1-0022483c8531\\\\\\\",\\\\\\\"@Microsoft.PowerApps.CDS.InnerError.Message\\\\\\\":\\\\\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\\\\\"}}\\\",\\\"_annotations\\\":{\\\"@Microsoft.PowerApps.CDS.HelpLink\\\":\\\""@Microsoft.PowerApps.CDS.TraceText\\\":\\\"[Microsoft.Dynamics.Service.Plugins:">go.microsoft.com/.../ Microsoft.Dynamics.Service.Plugins.PreOperationServiceAppointmentCreate\\\\r\\\\n[3f95a566-54ff-e611-80e7-00155db32b08: Create of serviceappointment\\\\r\\\\nEntered Microsoft.Dynamics.Service.Plugins.PreOperationServiceAppointmentCreate.Execute(), Correlation Id: 73633c68-18ca-4296-8b90-16ed7f254cb1, Initiating User: fe68f04b-3f9c-ed11-aad1-0022483c8531\\\\r\\\\nException: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist (Fault Detail is equal to Exception details: \\\\r\\\\nErrorCode: 0x80040217\\\\r\\\\nMessage: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\\r\\\\nTimeStamp: 2023-06-01T16:25:08.1774955Z\\\\r\\\\n--\\\\r\\\\nException details: \\\\r\\\\nErrorCode: 0x80040217\\\\r\\\\nMessage: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\\r\\\\nTimeStamp: 2023-06-01T16:25:08.1774955Z\\\\r\\\\n--\\\\r\\\\n)., Correlation Id: 73633c68-18ca-4296-8b90-16ed7f254cb1, Initiating User: fe68f04b-3f9c-ed11-aad1-0022483c8531\\\\r\\\\nExiting Microsoft.Dynamics.Service.Plugins.PreOperationServiceAppointmentCreate.Execute(), Correlation Id: 73633c68-18ca-4296-8b90-16ed7f254cb1, Initiating User: fe68f04b-3f9c-ed11-aad1-0022483c8531\\\",\\\"@Microsoft.PowerApps.CDS.InnerError.Message\\\":\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\"},\\\"_hasCustomerInfo\\\":false,\\\"_messages\\\":[\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\"},\\\"_message\\\":\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\",\\\"_exception\\\":null,\\\"_innerError\\\":null,\\\"_errorSource\\\":3,\\\"_blockErrorReporting\\\":false,\\\"_stack\\\":null,\\\"_faultedRequestIndex\\\":-1,\\\"_clientRequestId\\\":\\\"36331c07-113d-410f-90fe-5bb757a2226b\\\",\\\"_serverResponseId\\\":\\\"7dd7d1b0-d3ba-403d-b037-2dd3f2b93f1d, 82ec11ae-78c2-45ce-93c3-0bc049be3a1a\\\",\\\"_httpStatusCode\\\":404,\\\"_retryAfter\\\":null,\\\"_date\\\":\\\"2023-06-01T16:25:07.000Z\\\",\\\"_isRequestTooLong\\\":false,\\\"message\\\":\\\"Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist\\\",\\\"name\\\":\\\"Error\\\",\\\"stack\\\":\\\"No stack available.\\\",\\\"__action\\\":{\\\"source\\\":{\\\"actionType\\\":\\\"modernDataSource.execute.odata.async\\\",\\\"actionStack\\\":\\\"modernDataSource.execute.odata.async\\\",\\\"contextId\\\":\\\"266b8f79-ec14-49e3-9fb9-986c5d5febfe\\\"},\\\"child\\\":{\\\"actionType\\\":\\\"oData.create.async\\\",\\\"actionStack\\\":\\\"oData.create.async\\\",\\\"contextId\\\":\\\"046515b2-830e-4377-ad20-cb2d3f7f0928\\\"}}}\"}"
  5. title: "Record Is Unavailable"

And this one:

app.js?v=1.4.5757-2305.3:28 [storage Error Messages:
1: Entity 'serviceappointment' With Id = 480840da-9800-ee11-8f6d-000d3ae86f5e Does Not Exist

at K (mdf-carrusdev.crm3.dynamics.com/.../app.js
at new u (mdf-carrusdev.crm3.dynamics.com/.../app.js
at mdf-carrusdev.crm3.dynamics.com/.../mds.js
at mdf-carrusdev.crm3.dynamics.com/.../mds.js
at async Object.execute (mdf-carrusdev.crm3.dynamics.com/.../mds.js
Call stack hash: -2095811475

already try to clear my cache 

Any idea?

  • Suggested answer
    RE: error on service activity creation wit xrm.webapi.createrecord

    Found it.

    For the service activity(serviceappointment) creation you need the field scheduledstart and scheduledend.

    the end

  • RE: error on service activity creation wit xrm.webapi.createrecord

    Got the same error even with only the service activity creation parts in my code

  • Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: error on service activity creation wit xrm.webapi.createrecord

    the syntax is the one I wrote above, try to create a simple record without your function.

    Your error maybe is coming from another piece of your code as it refers a serviceappointment record with a specific id that is not part of your code, you should check this as well.

    hope it helps

  • RE: error on service activity creation wit xrm.webapi.createrecord

    Thank you, but still got the same error .

    Entity 'serviceappointment' With Id = 0f27841d-a500-ee11-8f6d-000d3ae86f5e Does Not Exist

    look like crm try to find the serviceappointment that he is creating .

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: error on service activity creation wit xrm.webapi.createrecord

    according to the metadata I have inside a trial, the syntax should be:

    var record = {};
    record["serviceid_serviceappointment@odata.bind"] = "/services(11111111-1111-1111-1111-111111111111)"; // Lookup
    record["regardingobjectid_incident_serviceappointment@odata.bind"] = "/incidents(33333333-3333-3333-3333-333333333333)"; // Lookup
    record.subject = "TEST"; // Text
    record.statecode = 0; // State

    regarding that error of XrmToolBox, make sure you are using the latest version of XrmToolBox before launching my tool, otherwise you can use the Managed Solution version or the browser extension version (chrome or edge).

  • RE: error on service activity creation wit xrm.webapi.createrecord

    Can you be more specific on what aim i doing wrong with the odatabind?

    I try your app but get this error when trying to connect

    Thank

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: error on service activity creation wit xrm.webapi.createrecord

    the odata bind properties of the lookups are not correct and the statecode should be an integer.

    Use my tool Dataverse REST Builder to see the exact syntax.

  • RE: error on service activity creation wit xrm.webapi.createrecord

    edit: the projectguid is an incident guid and the serviceActivity is a services activity that we use as template

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans