Skip to Content
0
Sep 23, 2015 at 07:19 PM

How-to create Service Request Note in Service Request from OData service

1083 Views

Hello dear C4C community,

I am currently developing a portal in HCP connecting our C4C demo system with the Portal.

I succeeded in creating tickets (Service Requests) from my UI5 application in the portal.

However, I am not succeeding in creating a Note (Service Request Note) in the Service request.

I just cannot find how to use the Navigation Property from the metadata of the OData service.

For the ServiceRequestCollection we have the following code as the Navigation property to Service Request Note in the $metadata.

<NavigationProperty Name="ServiceRequestNote" Relationship="c4c.ServiceRequest_ServiceRequestNote" FromRole="ServiceRequest" ToRole="ServiceRequestNote"/> 

I tried to expand my OData model like :

var oModel = viewElement.getModel();
        var oServiceRequest = this.createEntryObject();
        
        var params = {}; 
        params.success = this.createTicketSuccess; 
        params.error = this.createTicketError;
        
        oModel.create("/ServiceRequestCollection?$expand=ServiceRequestNote", oServiceRequest, params);

And this is how I assign values in my createEntryObject() function:

var oEntry = {};
oEntry.Description = name; //OK
oEntry.CustomerID  = "1000077"; //OK
oEntry.Priority = priority.toString(); //OK
oEntry.ReportedOn = reportedon.toString()+"T12:00:00Z"; //OK
oEntry.ServiceRequestNote = {}; //DO NOT WORK
oEntry.ServiceRequestNote.Text = "TestJAO"; //DO NOT WORK

However, when I do that I get this error message:

2015-09-23 15:04:33 [index.html] The following problem occurred: HTTP request failed400,Bad Request,<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>00145E5B1CC71EE0B2834BC2E9BE0C91</code><message xml:lang="en">The Data Services Request contains SystemQueryOptions that are not allowed for this Request Type</message></error>

It is the closest I came to create a Note in a Service Request.

I am lost now as I am not a pro developer in JS and UI5.

Any help on this matter would be greatly appreciated.

Thank you for your attention.

Best regards.

Jacques-Antoine Ollier.