Hello,
iâve successfully populated custom text field in ModuleB by selecting related field that points in ModuleA, however this does not works if instead clicking the button near to related field the autocomplete has been used.
Does anyone have a clue regarding how to let it works also with autocomplete?
Where:
account_name is the name of Account relate filed in Case module
account_id is the hidden id of Account relate filed in Case module
âindustryâ is the parent Account filed while âaccount_industry_câ is the destination Case field
âaccount_typeâ is the another parent Account filed while âaccount_type_câ is another destination Case field
Of Course, i am working in EditViewDefs of Case module, and this is just a proof of concept.
Then i will move to my real custom module.
@rainolf
Your code correct absolutely. I use this metod in my systems too.
I made your fields (âaccount_industry_câ and âaccount_type_câ) to use Studio in my test platform. After then I copied your code to file - custom/modules/Cases/metadata/editviewdefs.php and added the fields (âaccount_industry_câ and âaccount_type_câ) too. All working!
If data donât saved there is problem in somewhere else.
Sorry but probably i was not able to explain me well.
The code above works well just when you use the select button in related field in order to choose Accounts from popup search modal.
See attached:
But when you use autocomplete by typing first chars of Account name in related field and then select teh result it doesnât retrieve anything in the respective fileds.
See attached:
@rainolf
It was interesting case and the solution is very easy. I think that it may be interesting for a lot people.
Letâs add the custom file - âcustom/Extension/modules/Cases/Ext/Vardefs/account_name.phpâ
Hi,
i am doing additional test and iâve found in both situation(popup selection and quick search) that checkboxes cannot be populated. Moreover also option in dropdown cannot work if Name differs from value because it seems retrieving only the option name and not its own value.
Anyone came across this situation?
What would be an alternative way to do it(maybe with js on view) where also some source fields must be trasformed before being written to destination(ex: sum 2 source fields into one destination)?
Another issue iâve found is regarding currency fields.
In the source module has only 2 digits in decimal places while on destination 6.
@rainolf
I think that the field of type datetime will have problems too.
Javascript should be done for different types fields. popup selection and quick search get data only but they donât process them. The data can get into the hidden field and the javascript will process them.
But I think that it can use text fields in more situations. If data is taken from âparentâ module they should not be changed in âchildâ module.
@p.konetskiy would this method be suitable to have a relate field in the conversion process? Iâm trying to add a relate field to converdefs.php, not sure how I would implement it there.
Sorry I already figured this one out. This wasnât exactly what I was trying to do. I just wanted to add a normal relate field to the converdefs.php to populate on conversion. However, this gave me a good idea what I needed to do.
It seems you are the guy with all the answers (at least for me) lately
You were right; this is the exact situation I am facing: If the user identifies the related record by selecting the entry, the field_to_name_array works as expected and the local field is populated. But if the user starts typing in the field (instead of using the Select button) and chooses from one of the auto-complete suggestions, there is nothing populated in the local field.
I have tried using field_to_name_array to copy a text field to a text field
âSelect works, choosing from the autocomplete options does not
I have tried using field_to_name_array to copy over a datetime field
âSelect works, choosing from the autocomplete options does not
I was excited to see you have found a solution but I cannot get your solution to work. Any suggestions would really be appreciated.
In my case I am using a relationship (one-to-many) (and also a flex_relate field but we can deal with that later) so that may be complicating my situation. The field_to_name_array solution works for the one-to-many relationship as long as the user uses the Select button, but not if the user uses the autocomplete method.
Here is what I have
I have a custom module AYU_Funds, which records donations made at a Fund-Raising Event, with the Event being created by the FP_events core module.
I have created a One->Many relationship between AYU_Funds and FP_events. Each Fund-Raiser donation can only be associated with one Event but an Event can have many Fund Raiser Donations.
In custom/modules/AYU_Funds/metadata/editviewdefs.php
test_field_to_name_c is a text field (created in Studio) in the FP_events module
fp_events_ayu_funds_1_name is the holder of the Event name in the AYU_Funds module
fp_events_ayu_funds_1fp_events_ida is the holder of the Event id in the AYU_Funds module
receive_field_to_name_c is a text field (created in Studio in AYU_Funds) to hold the test_field_to_name_c content from the FP_events module
I have tried it with and without the additionalFields array and it makes no difference. I was told previously to use additionalFields for fields beyond the initial lookup fields (name and id) but if you think this is an issue, please advise.
As long as the user uses the Select button, just having the above makes the field_to_name_array work fine: the receive_field_to_name_c field in AYU_Funds is populated with the content of the test_field_to_name field from FP_events
But if the user uses the auto-complete and chooses one of the options put forward by the aut-complete, no content is added to the AYU_Funds field
So, to try and use your solution, I then added, into custom/Extension/modules/AYU_Funds/Ext/Vardefs/fieldToName.php
I donât know anything about array additionalFields.
Check the file cache/modules/AYU_Funds/AYU_Fundsvardefs.php . It should have populate_list and field_list arrays in the field array $GLOBALS["dictionary"]["AYU_Funds']["fields"]["fp_events_ayu_funds_1_name"]
If you are using the opcache module in php, you may need to restart the web server.
I use it in SuiteCRM 7. It works for all my projects.
One additional piece of information. Not sure it is relevant but I am on SuiteCRM v7.12.8
I did shutdown and restart the server
I removed the additionalFields array from the editviewdefs.php entry, just in case it was causing an issue. It did not make any difference but I left it out just in case.
I did check the cache at cache/modules/AYU_Funds/AYU_Fundsvardefs.php . Neither of the array entries
were there. Good catch. Not sure what is going on. The cache file is being updated with a QR&R; it is just not including the two array definitions.
Both array definitions were in custom/modules/AYU_Funds/Ext/Vardefs/vardefs.ext.php so the QR&R did its job and consolidated the vardefs for AYU_Funds.
But for some reason the two array definitions did not get included in the cache file.
I even tried re-defining the arrays by explicitly declaring the keys with
but that made no difference, so I put it back to the original. I guess it is not a surprise that it made no difference since the definitions are not getting to the cache file.
It is the same as before:
When using Select the content is transferred over
When using auto-complete, the content is not transferrred over
Three questions:
is there a setting somewhere in SuiteCRM that would interfere with the auto-complete functionality
what could possibly prevent something that was in
custom/modules/AYU_Funds/Ext/Vardefs/vardefs.ext.php
from being included in
cache/modules/AYU_Funds/AYU_Fundsvardefs.php
I did delete the cache file and after a QR&R the chache file was regenerated but with the same result
I did get a couple of things figured out and the cache file now does include the array definitions and al,l is working for text fields and datetime fields
When using Select the content is transferred over
When using auto-complete, the content is transferred over
What I did figure out was that I needed to ensure that the array definitions were loaded AFTER the original definition of the name variable fp_events_ayu_funds_1_name. Since the original defninition of the name vaiable was created in Studio (as a one->to->many relationship), it named the vardef file _override_fp_events_ayu_funds_1_AYU_Funds.php . Since I had named my file without the override prefix, the original vardef for fp_events_ayu_funds_1_name wiped out my array definitions and prevented them from being added to the cache file.
I renamed my file to be loaded after the original vardef file so I renamed it to _override_fp_events_fieldToName.php and now the cache file does include the array definitions.
So all is working, including a datetime field which I have added.
I now need to do the same for a Flex_Relate field. Letâs hope it goes well âŚ
hey @p.konetskiy you seem to be the guru of this topic. I just tried it out and it works great! I did have delete my cache file for it to work, I think this is definitely an important step. Quick question kind of relatedâŚ
Iâm adding this to a custom module (Transportation) and Iâve created Shipments (trans_Shipments) to capture shipments. Shipments ship to an account and Iâve used this to populate the address.
If I want to ensure this gets into my custom module package for export do I need to put it in:
/custom/modulebuilder/builds/Transportation/trans_Shipments/account_name.php or where do I put it so it remains part of the module builder if I have to rebuild it , or export the module?
Or will it just export if I just have it in the /custom/Extension/modules/trans_Shipments/Ext/Vardefs/account_name.php
@pstevens
I donât use the Module Builder. I create the installation package manually every time.
The file will add new field for system or custom module.