AnsweredAssumed Answered

quote_id is missing from product when quote is created via v10 api. custom code to bind relationship expected after it?

Question asked by Ron Lesh on Aug 14, 2018
Latest reply on Aug 14, 2018 by Ron Lesh

hey guys,

 

i am working on creating quotes through api request these days. 

 

i have followed this official documentation:

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Integration/Web_Services/v10/Example… 

 

I have also tired other option which is directly call the class to create quote:  (It should work the same as above)

$ModuleAPI = new \ModuleApi();
$this->quote = $ModuleAPI->createBean($RestApi,$quote_args);

 

The quote seems can be created fine. after i open the quote in application and all seems good and working.

*** However, i have noticed the quote_id value in products table actually only get updated when i open the quote from application. Before i open the quote, which is when just after create by api request. the quote_id value was null. It only get set after i open it in application.

( * somehow sugar will trigger a product save and quote save when i open the it. which i find a bit odd. may be it try to fix the missing relationship?)

 

if that value is missing. when we try to check by "$products = $quote->products->getBeans()". you will find you get an empty array. This is wrong!

 

i have tried to monitor the value when manually creating the quote on application. the value did get set after product saved. everything seems perfect.

 

so apparently there is a discrepancy between the quote that generated via api verses created manually from UI.

 

Did anyone experience the same? Does sugar except use to add custom code to update the quote_id back to the products after create by api request? Oh i forgot everything is done through rest api request, even when manually create it from UI. in this case, what additional step is expected by sugar to complete the quote creation? Did you guys all add additional code to quote_id to product after complete api request?

Outcomes