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?
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.
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.
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’
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.
I think that the field of type datetime will have problems too.
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.
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.
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