Skip to content

Manipulating Entries

icaton edited this page May 4, 2011 · 16 revisions

get_entry()
get_entries()

Get Entry List

Get entry list is used to get a list of entries from the sugarcrm database. The function itself can be found here and it looks like this:

def get_entry_list(self, module_name, query ="", order_by ="", offset = 0, select_fields = [], link_name_to_fields_array = []):

We have already discussed how modules work and you will put that into the module_name parameter. We will be using Accounts for these examples. Now if you just put in a module name and leave everything else blank, as such:

entry_list = session.get_entry_list('Accounts',"","","",[],[])

You will get a really long list of every entry in the Accounts module. So it's important to specify a bit with what you are looking for. Let's use a specific industry type to focus our search a bit. We will use the query field to do this.

entry_list = session.get_entry_list('Accounts', "accounts.industry = 'retail'", "","",[],[]) or entry_list = session.get_entry_list('Accounts', "accounts.billing_address_state = 'CA'","","",[],[])

Adding queries like this will help limit your search a bit, but it will still come back with way more information then we need. So we need to be a little bit more specific with our searches. Now we will add information to the select fields parameter.

entry_list = session.get_entry_list('Accounts', "accounts.industry = 'retail'", "","",['id','sic_code'][])

You get much shorter output and closer to what we want, which looks like this:

get_entry_count()

set_entry()
set_entries()

Clone this wiki locally