I have created a custom module (TimeManagement) and custom code to run pre defined data into fields based on drop downs, this was working fine when the custom module was related to just one peer module ie it was related originally to contact then i related it to account, the code works fine in contact but only part works in account
so the code as it stands just populates a year field in the submodule after first selecting the dropdown for month, the next part of the code generates a custom name in the name field based on the drop downs, i stripped back the code to just 1 line for test purpose which is
"document.getElementById(‘name’).value = ‘test’; "
but this only works when adding the quickcreate from from contact, it doesnt work from account but the rest of the code below works from both accounts and contacts, ive been pulling my hair out for days now looking for a solution so if anyone can help much appreciated, i have even remove the relationships all together on this module and just added back the accounts module and this still doesnt work.
var currentyear = new Date().getFullYear();
document.getElementById(‘year_c’).value = currentyear;
PS no amount of repairing (every repair) has helped nor clearing browser cache, i have been doing custom code for a good number of years and never seen this happen before.
Thanks in advance
Hi,
Share some screenshot of what is appearing now and what is missing.
How are you embedding the code into the View?
This is working from contacts module, you see test in the name appears ok, but when the very same sub gets done from accounts module the name is blank but the year is still ok
snip of code from quickcreate defs
array (
0 =>
array (
0 =>
array (
‘name’ => ‘month_c’,
‘studio’ => ‘visible’,
‘label’ => ‘LBL_MONTH’,
‘displayParams’ =>
array (
‘field’ =>
array (
‘onchange’ => ‘updatename();’,
),
),
),
snip from function called, i stripped it right back
function updatename(){
document.getElementById(‘name’).value = “test”;
var currentyear = new Date().getFullYear();
document.getElementById(‘year_c’).value = currentyear;
}
check the field names in Account module…
The field name should be the same like you have in contacts module. Do it with developer tools by pressing F12 and then go to elements.
1 Like
ok so you took me down a route that i remember there was a problem before and its because the page has to fields with the id “name” that is most likely why, i just remembered i had a similar issue previously, the field description is doing exactly the same to which that also is visible on both main and sub, will test, thanks for jogging my memory
ok so as a test i ran the same code on the description field and it doesnt work, i then removed the description field from the accounts form and the code works fine on the subform, main issue i have now is i need to generate my name based on dropdown results soi may need to run a query or something
Removing the “name” field from the accounts detail view resolved the issue as the code tries to lookup the field by id and the accounts name is the first id.
1 Like