No Match for Field: Leads Error

I created a custom module that has a Relate field to Leads. And then it autofills the address fields in the custom module from the address fields from the Lead module. When I type in a Lead and select it, all fields correctly autofill but when I go to save the file I get this error.

No match for Field: Lead Name (Lead Name being the name of the Relate Field)

Can someone help me troubleshoot this? Ive exhausted my options.

Hi Chris,

I’ve tried this on a local 7.11.15, and I think i’m able to replicate, so it may be a bug

I’ve created a Module, and as part of this, included a One-to-One relationship to Leads
When editing a record in this custom module, the Leads relate field doesn’t save a value

However, I created a 2nd custom module, (Not adding a relationship to leads)
Then, after deploying the module, I added a relationship to leads in studio

This relationship seems to work, and I am able to relate the 2nd custom module to Leads successfully

At what stage in module creation are you adding the relationship?

If you do the above, and add the relationship through studio after deploying a custom module, are you able to use the relationship?

There also seems to be a current bug on the SuiteCRM github wherein the user added >10 relationships:

Does this seem related?

Hi John,

Originally I didnt create a relationship, only added the Relate field, Error appears.

Once I created the module, I did everything else in studio. So I added the relationship between my custom module and the lead module (one to one) and I still get the same Error even after a QR&R.

Could it be the code I put in to autofill that is causing the error?

$dictionary['samp1_Sample_Request_Lead']['fields']['lead_name_c']['populate_list'] = array('name', 'id', 'primary_address_street');
$dictionary['samp1_Sample_Request_Lead']['fields']['lead_name_c']['field_list'] = array('account_name', 'account_id_c', 'address_c');

I commented out the code and I can now save Leads without that error. But I have been able to put that same code into a similar custom modules that does the same but with Accounts instead of Lead. Exactly the same way. Hmm…


It could be down to the way that “Person” type modules use “Name”

As far as I’m aware, “Company” type modules, such as Accounts, have just a single “Name” field

Whereas modules like Leads & Contacts instead make use of a concatenated “Name” field that’s made up of first_name+last_name
(Which is what gets displayed on Listview/Detailview, for example)

Perhaps, instead of using "name" for Leads, you could try "full_name"? That seems to be what Leads uses for the concatenated "Name" field it displays on List/Detailview, so you might have some luck with that

Otherwise, I’m not too sure
Perhaps you’d have to use first_name and last_name seperately?

Ah, I see. That looks like that could be the problem. How do you think it should be written?

I tried:

$dictionary['samp1_Sample_Request_Lead']['fields']['lead_name_c']['populate_list'] = array('full_name', 'id', 'primary_address_street');
$dictionary['samp1_Sample_Request_Lead']['fields']['lead_name_c']['field_list'] = array('account_name', 'account_id_c', 'address_c');

No luck as well as:

$dictionary['samp1_Sample_Request_Lead']['fields']['lead_name_c']['populate_list'] = array('last_name', 'id', 'primary_address_street');
$dictionary['samp1_Sample_Request_Lead']['fields']['lead_name_c']['field_list'] = array('account_name', 'account_id_c', 'address_c');

But I still get that same error. I understand what could be the issue but I cant figure out a work around. Do you have any suggestions? Much appreciated.


hmmm, if none of “full_name”, “name” or “first_name”/“last_name” provide results, i’m not too sure…

Maybe there are other places in the CRM with similar behaviour, (specifically around Leads), in the CRM that might give some hints?

One that comes to mind is the Lead Conversion process, as that relates a few different modules to Lead records
eg, in the /modules/Leads/tpls/ConvertLead.tpl file, I’ve found it uses the following snippet, with a $module variable provided:

    field_list    : ['name', 'id'],
    populate_list : ['{$selectFields.{{$module}}}', '{$contact_def[$selectFields.{{$module}}].id_name}'],
    conditions    : [{ldelim}'name':'name','op':'like_custom','end':'%','value':''{rdelim}],

Otherwise, maybe as a workaround, you could try creating a new custom field that just copies the "Name" value (via Logic Hook) Then, try using that field in the "populate_list" array?

I think the issue is that there’s not a concrete “Name” field in the Leads module (ie, No Database column)
So hopefully by making a new field with the same value, we would be able to achieve the same thing?

However, if the above fails, I'm afraid I'm also stumped :slightly_frowning_face:

Perhaps someone more well versed in the sqs_objects has any ideas?

No luck messing around with this. I decided to make the autofill happen on save with a Workflow instead of the custom code. Thank you @John for your help, if anyone else has any ideas on this please post!