👋🏾 Looking to join our SuiteCRM Community Working Group? 💌 Open invitation throughout January. Check out all the details here 👈

Need help showing related fields in listview

So we are using the Opportunities feature, but want to show either the billing or shipping address in the Opportunities ListView of the associated customer.

Is there a way of “linking” these in studio somewhere? So that when browisng the list view of Opportunities, we can quickly see the associated customers address right there without having to click into it?

1 Like

You may try with a custom Logic Hook. I believe that the code required should be quite simple if you are satisfied with pulling the address and display it on the DetailView.

Well for whatever reason these people want it displayed on the List View of the Opportunities. Ill have to look into logic hooks and where to even start with coding that.

You can do it also on a ListView

Maybe you can also do it without coding:

  1. Create a custom field using Studio in the opportunities module
  2. Add this field in the listView and the DetailView (don’t put it in EditView and make sure that inline edit is off)
  3. create a workflow that takes the address and puts it in the new field. (you may try to combine the various parts of the address field as only one field using a calculated field)

This should take around 30 minutes to create I believe.
In this case no coding required.

And if I want to simply take the Billing Address State from Customer to the custom field of State for the Opportunity, what would the formula for that be?

Would it be something like {replace({p0},{p1})}

If you just want one value you don’t need a calculated field. You can simply assign it to the field in opportunities.

I must be dense but I dont see how to take a value from the Customer record associated with the Opportunity and getting a value from there into the Opportunity.

I.E an Opportunity has an associated Customer record linked by “Customer Name” in the Opportunity.

I need to get into that customer, and pull the state/city its from and put it in the Opportunity.

Not seeing how to do that using workflow aciton “modify record”

You are right. Not possible withouth calculated field.

So I tried with a calculated field and it worked.

First I created a custom field in studio called “city” for opportunites
Then I added it to the Detail view

Then I created the following workflow:

When I see the detail view now I have the value of the account billing city.

Potential problem: in the way I have created it, if you change the value of the city in the account, it won’t be synchronised in the opportunity unless you edit it and save (this triggers the workflow)

Another solution top this problem consists in adding a condition to the workflow or possibly create a second workflow that updates the value when the account is modified.

Please post if it works!

1 Like

Hey man, first thanks for this small tutorial.

Want to know where Im wrong cause I’ve done this and it dont work.

What I want :

Some account are sponsored by contact.A contact can sponsor multiple Account, an account is sponsored by one contact.

So in the account module I have a field “sponsored by” and its a related field to a contact. So I’ve create a related field.

So problem is that I see who sponsored an account, but In contact module I dont see wich account the contact have sponsored.

I know that there is relationships, but I want it in a field. not In the small pannel under the form.

Dont work with the workflow… Maybe I need to serch better on this forum cause I cant be the only one who want to do something like that !

we added a non-db field which pulls data via a custom function, here’s an example

   array (
      'required' => false,
      'name' => 'sales_reps_full_name',
      'vname' => 'LBL_SALES_REPS_FULL_NAME',
      'type' => 'text',
      'massupdate' => 0,
      'no_default' => false,
      'comments' => '',
      'help' => '',
      'importable' => 'true',
      'duplicate_merge' => 'disabled',
      'duplicate_merge_dom_value' => '0',
      'audited' => false,
      'inline_edit' => true,
      'reportable' => true,
      'unified_search' => false,
      'merge_filter' => 'disabled',
      'size' => '20',
      'studio' => 'visible',
      'rows' => '4',
      'cols' => '20',
      'source' => 'non-db',
      'function' => 
      array (
        'name' => 'CommonUtils::getSalesRepsFullName',
        'returns' => 'html',
        'include' => 'custom/modules/ODS_Inventory/Utils/CommonUtils.php',
        'onListView' => true,
      ),
    ),

and the func for getSalesRepsFullName is

class CommonUtils
{
    /**
     * Возвращаем имена всех брокеров связанных с квартирой, через запятую
     * @param $inventory
     * @return string|null
     */
    static function getSalesRepsFullName($inventory)
    {
        if (!is_array($inventory) || empty($inventory['ID'])) {
            return null;
        }
        $return = array();
        global $db;
        $query = "SELECT users_id FROM users_ods_inventory WHERE ods_inventory_id = '{$inventory['ID']}' AND deleted = '0'";
        $result = $db->query($query);
        while ($row = $db->fetchByAssoc($result)){
            $return[] = BeanFactory::getBean('Users',$row['users_id'])->full_name;
        }
        return implode(', ' , $return);
    }

you can then specify the field name in listviewdefs.php like so:

  'SALES_REPS_FULL_NAME' =>
  array (
    'type' => 'currency',
    'currency_format' => true,
    'studio' => 'visible',
    'label' => 'LBL_SALES_REPS_FULL_NAME',
    'width' => '10%',
  ),
1 Like

@robert_sinclair if you put your code inside triple-backticks, you get nice colored syntax-highlighting :smiley:

```
code
```

thank for the tip! done :wink:

1 Like