-
Notifications
You must be signed in to change notification settings - Fork 32
Manipulating Entries
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
We can find out how many entries exist in a specific query. The get_entries_count() function can be found here The function call looks like this:
get_entries_count(self, module_name, query = "", deleted = False):
So you can see that it uses the same parameters as in the get entry list call. So we will use the same parameters as above to see how many entries are in the query that we gave get_entry_list().
entries_count = session.get_entries_count('Accounts', "accounts.industry = 'retail'")
Which will give us the following output:

So this specific query, given to get_entry_list(), gives us the result of how many field entries exist there.
set_entry()
set_entries()