cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to Create multiple items in existing Opportunity using Odata Service in sap c4c

0 Likes
1,160

Hi Folks ,

I need to create multiplue items in existing Opportunity using Odata in SAP C4C.

It would be very great if some one please provide solution with example.

Regards,

Sunny

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Likes

Hi Saurabh ,

Thanks for your reply ,

You are right we can do it by $batch option in post method that is one of the option(alternative).

I have created multiple items in existing service request in one of my project long back.

Please check the below payload but somehow it is not working right now. If we can create one item in existing opportunity or then why we can do it with multiple item.

Create request with multiple item in new ticket

UrL

Post Request https://myxxxxxx.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ServiceRequestCollection

{ "ProcessingTypeCode":"###", "Name": "Testing for Postman",

"ServiceRequestItem" :

[

{ "ID":"10",

"ProductID":"IDdata"

},

{ "ID":"20",

"ProductID": "IDdata"

}

]

}

Create items records in existing Ticket

Post Request

https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ServiceRequestCollection('001XXX3E64DDBB1ED8XXXXXXXXX')

{ "CustomFields": "10",

"ServiceRequestItem":

[

{ "ID":"10", "ProductID":"100000", },

{ "ID":"20", "ProductID":"100001", }

]

}

like wise we can do it with opportunitycollection

Regards,

Sunny

former_member226
Employee
Employee
0 Likes

Hi,

There could be multiple explanations for the above-said behavior:

1. ServiceRequest and Opportunity both are using different BO and hence different implementation for their respective odatas. hence it is not necessary if ServiceRequestCollection offers something then it will also be available for opportunity collection. Whatever is written is odata guide has to be followed as this guide is prepared by expert/developers.

2. If something was working earlier but not working anymore then it has to be raised as a bug to SAP support for a fix. Can you please do that? In general with each new release whatever feature comes up, then they are also backward compatible, and if not then SAP usually informs them in webinars. I believe payload which you shared could have been from c4codata (v1 api) instead of c4codataapi (v2 API) , and this could be the reason for the same

former_member226
Employee
Employee
0 Likes

Hi,

Pls have a look at official odata documentation at the following link:

https://help.sap.com/doc/d0f9ba822c08405da7d88174b304df84/CLOUD/en-US/index.html#/topic/OpportunityI...

Here you should be able to find about the same under the title"Create New OpportunityItem".

Further you cannot add multiple products in a single call to opportunity, hence you need to make a POST call either for each opportunity item one by one or using $batch end point as mentioned here: https://answers.sap.com/questions/13102793/add-multiple-products-to-an-opportunity-using-sap.html