SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me
Support for Advanced Open Workflow, Sales, Portal for SugarCRM Community Edition

TOPIC: Adding line items to contract via REST API

Adding line items to contract via REST API 1 year 3 days ago #59892

  • gunnerman
  • gunnerman's Avatar
  • Offline
  • New Member
  • Posts: 18
  • Thank you received: 3
  • Karma: 0

I am having a jiggery pickery of a time creating/adding line items to a contract using SuiteCRM's REST API from a web app. We are using Suite 7.8.13. I don't understand the relationship structure well enough to figure out what is going on and I hope someone would be kind enough to point me in the right direction.

I create a contract and set the account and contact relationships easily enough,
$suite_contract = $suite_crm->create_single_record( 'AOS_Contracts', $sContract );
$suite_crm->set_relationship( 'Accounts', $account_id, 'aos_contracts', [ $suite_contract->id ], [] );
$suite_crm->set_relationship( 'Contacts', $contact_id, 'aos_contracts', [ $suite_contract->id ], [] );

Additionally, I can set the Contract Manager relationship by adding the assigned_user_id name and value to the contract creation request data ($sContract).

Then I try to add the line items by first creating an AOS_Product_Quote and then using
$suite_crm->set_relationship( 'AOS_Products_Quotes', $aos_product_quote_ID, 'aos_contracts', [$suite_contract->id], [] );
to relate it. It says the relationship was created however it is not added to the contract.

From a different forum post, I found that if I add a line item to a contract from the web interface in CRM I can retrieve that line item data by defining related_module_link_name_to_fields_array in the request,
$suite_crm->get_entry('AOS_Contracts',$suite_contract->id,[],[['name'=>'aos_products_quotes', 'value'=>['id','name','parent_id','parent_type','product_id','parent_name','aos_products','aos_contracts']]]);
but I don't understand how this works for setting a relationship in this case. Is the name_value_list in a set_relationship call related to the related_module_link_name_to_fields_array in any way?

The administrator has disabled public write access.
Time to create page: 0.049 seconds
Powered by Kunena Forum