CRM and CX Blogs by SAP
Stay up-to-date on the latest developments and product news about intelligent customer experience and CRM technologies through blog posts from SAP experts.
cancel
Showing results for 
Search instead for 
Did you mean: 
palu
Product and Topic Expert
Product and Topic Expert
5,340
Overview:

In this blog post, we are going to see how to create Service Request and its Item details ( Item, Attachments, Involved Parties) using the Odata function Deep Insert in SAP Cloud for Customer system.

Answers to expect from this post?

  1. How to use Deep Insert in Odata Service Explorer

  2. What is the format we need to follow in a Deep Insert Payload


Let's get started:

Step 1 :

Log in to your SAP Cloud for Customer System.

Go to Administrator Work center -> OData Service Explorer.

Select the Service c4codataapi and Click Test.

 


In the Odata Console, Choose ServiceRequestCollection among the list of Entity Sets.

As you can see, the Service Request Collection is associated with Multiple Child Entities like ServiceRequestAttachmentFolder, ServiceRequestItem, etc.

Step 2 - Creating the Payload :



Navigate to the Tab Test.

 

In the Request Method, Choose Deep Insert and choose the Payload format as JSON.



 

By using Deep Insert, We can create Parent (ServiceRequest) and Items ( ServiceRequestItem , ServiceRequestAttachmentFolder) in one call instead of multiple POST calls for Parent and Child entities.

In the Payload, The name of the child entities needs to be given followed by its data. For Parent Entity ServiceRequest, We are passing only the field "Name", since this field is enough to create a Service Request in C4C.

Payload Example :
{     
"Name" : "Test",
"ServiceRequestItem":
[{
"ProductID" : "10001092"
}],

"ServiceRequestParty":
[{
"PartyID" : "10332",
"RoleCategoryCode" : "10",
"RoleCode" : "10",
"Main" : true
}],

"ServiceRequestAttachmentFolder":
[{
"TypeCode":"10001",
"MimeType":"text/plain",
"Binary":"VGVzdCBBdHRhY2htZW50",
"Name":"Test.txt",
"CategoryCode":"2"

}]
}

Once you execute the above Payload, you will get a success message,which means the record was created in the system.


 

Response :

As we can see from the response below, a new Service Request with ID 11192 got created.


Step 3 - Check the Data in the system :

Go to Tickets Work center and search for the Service Request ID, Which you got in the Response.

Attachments :


 

Involved Parties :


 

Items :


 

Conclusion:

  1. Commas and brackets are used to separate the entities in the Payload. Double-check the syntax, since missing a single comma will result in an error.

  2. You can also post records from an external application like Postman. But, you have to request x-csrf token to post records. Since the method Deep Insert is not available in Postman Tool, You have to use POST with the same payload.

8 Comments