Customize the relational dropdown in SuiteCRM 8

Hello everyone, I have two questions and I would appreciate any help. They are related to the new dropdowns in SuiteCRM 8 when creating a one-to-one relationship:

  1. Can I, apart from the default name field from the related module, add another field? For example: code_custom - name.
  2. Is there a way to pass a parameter to the dropdown to filter the data it returns?

Thank you very much for any assistance!

Check if you have any options in the studio:

Admin → Studio → Module → …

Hi @rsp
No, this cannot be configured through Studio. I’m asking if it can be done programmatically.

Maybe it is possible. What module you’re using?

What exactly are you trying to do here?

Sorry for the lack of context.

I am in the Cases module, which has a relationship with Accounts (this relationship is native). The dropdown for this relationship loads the account names. I created a field in the Accounts module called “code,” and I want the dropdown to display:
code_account - name_account

It looks you need to combine two fileds while searching an account to link a case with. I think we can specify only one column to use for the search operation. In your case you can concatenate code with name while saving the account and don’t do anything for the case account name. If you want to search an account using the code your can add a nondb field in vardefs file. For this you can refer the following example where search is using phone office column.

1 Like

Hi @Harshad
Thank you very much, it worked perfectly. However, in the detail view, it still only displays the account name. I believe this is because it is rendering the component located at:

core/app/core/src/lib/fields/relate/templates/detail/relate.component.html.

I tried adding a 'customCode' to the field in the metadata, but it doesn’t recognize it, as it seems to go directly to the related field component.

If you have any idea of what I could try to achieve the visualization in the detail view as well, I would greatly appreciate it.

Thanks for the reply. I think the detail view should show the value of rname column. Are you able to search by account code in edit and it doesn’t show account code but account name on the detail view?

correct the field in the edit is the one I added in the rname but the detail shows me the default which is the name of account

I have the following in my test instance where I can see an account phone number value on the detail view. Here is vardef code.

<?php
        $dictionary['Case']['fields']['account_phone'] = array(
            'name' => 'account_phone',
            'rname' => 'phone_office',			
            'id_name' => 'account_id',
            'vname' => 'LBL_CASE_ACCOUNT_PHONE',
            'type' => 'relate',
            'link' => 'accounts',
            'table' => 'accounts',
            'join_name' => 'accounts',
            'isnull' => 'true',
            'module' => 'Accounts',
            'dbType' => 'varchar',
            'len' => 100,
            'source' => 'non-db',
            'comment' => 'The name of the account represented by the account_id field',
			'studio' => 'false',
        );

image

4 Likes

Hi @Harshad thank you very much it worked
my mistake was that I had overwritten the account_name instead of creating a new one, thank you very much.

@Harshad Awesome! Glad to see this method still works in SuiteCRM 8.

1 Like