cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jacques-Antoine
Active Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

To answer your question, you need to understand the underlying business object first so you know what to do in the API to manipulate the data in the business object.

The Service Request is a "complex" business object.

It has:

1. Header (root)

2. TimePoints 1:N to the root (node that stores all of the various time stamps for SLA and during the lifecycle of the ticket)

3. Parties 1:N to the root (node the stores all of the different "parties" attached to the ticket such as ship-to, bill-to, seller, customer, processor, service org, etc...)

4. ServiceReferenceObjects 1:N to the root (node that stores the "products" attached to the ticket like ibase, ipoint, registered product, product. Tip: on the UI we show the "main" instances of these products, but the model supports N instances -> more than one ibase, ipoint, registered product, product)

5. Items 1:N to the root (node that stores the line items of the ticket)

6. TextCollection 1:N to the root (node that stores the notes of the ticket)

7. AttachmentFolder 1:N to the root (node that stores the attachments of the ticket)

8. BusinessTransactionReference 1:N to the root (node that stores references to other C4C transactions such as emails, tasks, social media messages, SMS messages, chat messages, appointments, visits, surveys, tickets, leads, opptys, contracts)

Screen shot below of the details of the object in the SDK "Repository Explorer". This is available when you login SDK into your tenant you will have access to the "PSM" (public solution model) which is what we publish to partners and customers to consume our objects via API and SDK. The Repository Explorer will details about the object, datatypes that you can access via the oDATA explorer.

So to create notes, at a high level, you will need to find the oDATA structure that maps to the TextCollection node of the Service Request. In this structure, you will need to create an instance of the text collection, set the languagecode, typecode, and text. Since you will create the textcollection is part of the servicerequest, it will know that when you create the textcollection it will automatically link it with the servicerequest. If you need details of the code value you need to default/set for the languagecode/textcode then use the repository explorer to find the datatype which give you a complete list of supported code list values.

Answers (2)

Answers (2)

carlos_hidalgo
Explorer
0 Kudos

Hi Rei Kasai .

Can you please let me know if is it possible to read the Service Request Change Log using SDK ?. I cannot see a node with the log data inside the ServiceRequest BO.

Thanks in advance for your help!.

0 Kudos

Hi:

You can refer to the sample payload for Update Tickets section https://github.com/venkyvb/c4c-api/blob/master/sections/serviceticket.md. Here you ignore the $batch payload part but just use the payload under POST ServiceRequestTextCollectionCollection.

Best regards

Venki

Jacques-Antoine
Active Participant
0 Kudos

Thank you for your answer .

However, it seems this solution was working for the previous OData structure in C4C but not since the revamp of the ServiceRequestCollection.

Now, the endpoint myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4c.svc/ServiceRequest does not exist anymore.

To Retrieve the ServiceRequestNote, we need to go through the navigation property like:

<link href="ServiceRequestCollection('00163E0E265E1ED598DC2E74E81964A8')/ServiceRequestNote" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ServiceRequestNote" type="application/atom+xml;type=feed" title="ServiceRequestNote"/>

Where 00163E0E265E1ED598DC2E74E81964A8 is the UUID of the Service Request.

Here is the corresponding XML if I query the created instance through POST OData (UI5 Starter widget app).

There is no ServiceRequestTextCollection in my OData structure (same as the XML structure below).

I get no error when I try to do like:

    oEntry.TextCollection = {};
   oEntry.TextCollection.Text = "TestJAO";
   oEntry.TextCollection.TypeCode = "10007";

where oEntry is the parameters I use to create in my OData model, however it does not create any TextCollection in the backend.

I will try other things to see if I succeed, but for now I am still stuck.


<entry xml:base="https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/c4c.svc/">

<id>

https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/c4c.svc/ServiceRequestCollection('00163E0E265E1ED598...')</id>

<title type="text">Test JAO TExtCollection</title>

<updated>2015-09-24T17:31:52Z</updated>

<category term="c4c.ServiceRequest" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<link href="ServiceRequestCollection('00163E0E265E1ED598DC2E74E81964A8')" rel="edit" title="ServiceRequest"/>

<link href="ServiceRequestCollection('00163E0E265E1ED598DC2E74E81964A8')/CorporateAccount" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/CorporateAccount" type="application/atom+xml;type=entry" title="CorporateAccount"/>

<link href="ServiceRequestCollection('00163E0E265E1ED598DC2E74E81964A8')/ServiceRequestNote" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ServiceRequestNote" type="application/atom+xml;type=feed" title="ServiceRequestNote"/><link href="ServiceRequestCollection('00163E0E265E1ED598DC2E74E81964A8')/TicketInvolvedParty" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/TicketInvolvedParty" type="application/atom+xml;type=feed" title="TicketInvolvedParty"/><content type="application/xml">

    <m:properties>

        <d:AssignedTo>Jacques-Antoine Ollier</d:AssignedTo>

        <d:CRMUILink>https://my302788.crm.ondemand.com/sap/public/byd/runtime?bo=COD_SRQ_AGENT_TT&nav_mode=TI&param.Key=0...</d:CRMUILink>

        <d:ChangedOn>2015-09-24T17:26:56.6301620Z</d:ChangedOn>

        <d:CompletionDate m:null="true"/><d:CompletionDateTime/>

        <d:CompletionDue>2015-09-25T17:26:56.0000000Z</d:CompletionDue>

        <d:CompletionDueDateTime>2015-09-25T17:26:56Z</d:CompletionDueDateTime>

        <d:CustomerID>10005</d:CustomerID>

        <d:CustomerName>FutureVision</d:CustomerName>

        <d:DaysUntilDueDate>1</d:DaysUntilDueDate>

        <d:Description>Test JAO TExtCollection</d:Description>

        <d:EscalatedOn m:null="true"/>

        <d:EscalatedOnDateTime/>

        <d:EscalationStatus>1</d:EscalationStatus>

        <d:EscalationStatusText>Not Escalated</d:EscalationStatusText>

        <d:ID>3745</d:ID>

        <d:IncidentCategory/>

        <d:InitialReviewDue>2015-09-24T17:56:56.0000000Z</d:InitialReviewDue>

        <d:InitialReviewDueDateTime>2015-09-24T17:56:56Z</d:InitialReviewDueDateTime>

        <d:LastAgentInteraction m:null="true"/>

        <d:LastAgentInteractionDateTime>20150924182656.0000000</d:LastAgentInteractionDateTime>

        <d:ObjectID>00163E0E265E1ED598DC2E74E81964A8</d:ObjectID>

        <d:PartnerName>Matthias Brunner</d:PartnerName>

        <d:Priority>3</d:Priority>

        <d:PriorityText>Normal</d:PriorityText>

        <d:ProductCategory/>

        <d:ProductDescription/>

        <d:ProductID/>

        <d:ReferenceDate m:null="true"/>

        <d:ReferenceDateTime/>

        <d:ReportedBy>Matthias Brunner</d:ReportedBy>

        <d:ReportedOn>2015-09-24T17:26:56.0000000Z</d:ReportedOn>

        <d:ReportedOnDateTime>2015-09-24T17:26:56Z</d:ReportedOnDateTime>

        <d:SerialID/>

        <d:ServiceCategory/>

        <d:ServiceCategoryID/>

        <d:ServiceRequestClassificationCode/>

        <d:ServiceRequestClassificationCodeText/>

        <d:Source>1</d:Source>

        <d:SourceText>Manual data entry</d:SourceText>

        <d:Status>1</d:Status>

        <d:StatusText>Open</d:StatusText>

        <d:Team>Level 1 Support Queue</d:Team>

        <d:TeamID>S3110</d:TeamID>

        <d:TicketUUID>00163E0E-265E-1ED5-98DC-2E74E81964A8</d:TicketUUID>

        <d:Warranty/>

        <d:WarrantyFrom m:null="true"/><d:WarrantyTo m:null="true"/>

    </m:properties>

</content>

</entry>

Thank you very much for your attention.

Best regards.

Jacques-Antoine Ollier