lingxiao
lingxiao

Reputation: 1224

How to set entry for custom modules in sugarcrm?

I'm using the following package: https://pypi.python.org/pypi/sugarcrm/0.1

using the following code i'm able to create a lead:

import sugarcrm

# Connect
url = "http://localhost:8080/service/v4/rest.php"
username = 'admin'
password = 'admin'
session = sugarcrm.Session(url, username, password)

# Create a lead
lead = sugarcrm.Lead(first_name="Tester",
                     last_name="Test",
                     email1="[email protected]",
                     description="Submit",
                     do_not_call=True)

session.set_entry(lead)

However, I have some custom modules in the crm to maintain and I can't find any way of creating entries in those modules. Does anyone know how?

Upvotes: 0

Views: 273

Answers (1)

lingxiao
lingxiao

Reputation: 1224

One of the custom modules I have is called APPSV_Credit_Cards. Looked at the source code of https://pypi.python.org/pypi/sugarcrm/0.1 and found out the following worked:

>>> class CreditCards(sugarcrm.SugarObject):
...     module = "APPSV_Credit_Cards"
... 
>>> creditCards = CreditCards()
>>> creditCards
<__main__.CreditCards instance at 0x7f72c1e2fc68>
>>> crmSession.get_entry_list(creditCards)
[]
>>> creditCards = CreditCards(name='AMEX Platinum', product_code='AMEXPLT', product_desc='American Express Platinum Card')
>>> response = crmSession.set_entry(creditCards)
>>> response = crmSession.get_entry_list(creditCards)
>>> response[0].__dict__
{'modified_user_id': u'916110f8-f8cb-fc6c-9d78-58357676adce', 'date_entered': u'2016-12-11 04:31:38', 'name': u'AMEX Platinum', 'date_modified': u'2016-12-11 04:31:38', 'deleted': u'0', 'created_by_name': u'Usercity API', 'product_desc': u'American Express Platinum Card', 'assigned_user_id': u'', 'module': 'APPSV_Credit_Cards', 'modified_by_name': u'Usercity API', 'assigned_user_name': u'', 'product_code': u'AMEXPLT', 'id': u'dba547ee-fc95-b088-f39c-584cd647ae75', 'created_by': u'916110f8-f8cb-fc6c-9d78-58357676adce', 'description': u''}
>>> 

Upvotes: 1

Related Questions