HOWTO: Export records based on criteria from a related record.

sugarcrmdevelopers —  March 22, 2012 — 3 Comments

Here’s a fun request I saw a while back on the forums…

It would be great if you could export contacts while filtering on other object criteria. A simple example would be, if I wanted to export all contacts that are associated to accounts of type “Customer”. It is simple, but a huge help so I don’t have to chase this data down directly from the database.

I’d be lying if it’s the first time I’ve seen a request like this, and often it requires you doing some oddball code level changes in the SearchFields definitions which can be a bit daunting to say the least. Luckily with Sugar Logic in Sugar 6.3 and later you can have a calculated field that can grab a value from a related record, making this much easier to do.

So to do what the poster is asking, try these steps:

  1. Go into Studio, and add a new TextField in the Contacts module named ‘account_type’
  2. In the field definition, checkbox ‘Calculated Field’ and put in the formula

    into Formula Builder.

  3. Save the field
  4. Add the field in the layout of the ListView and the Search ( either Advanced or Basic, depending upon your preferences ) for the Contacts module.
  5. Go to the Contact ListView, and do a search for “Customer”
  6. Click the checkbox down arrow and choose ‘Select All’
  7. Click ‘Actions’ and then ‘Export’ to export the records.

3 responses to HOWTO: Export records based on criteria from a related record.


    Added the new field into the Contact module….there isn’t a box that has field definition or checkbox for ‘Calculated Field’ in 6.4 CE SugarCRM.
    What is the datatype “Relate” used for? That looks like the proper one to use but I can’t find anything on it in the docs or forums.


    Remarkable! Its actually remarkable post, I have got much clear idea on the topic of from this paragraph.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s