Difference between revisions of "Onloadfunc"
(Created page with 'You can use '''onloadfunc''' to create a custom Browser Script that runs whenever a record is first opened. * This is in place in the UTA at Level 1, Level 2, Level 3 and Inv…') |
|||
Line 16: | Line 16: | ||
} | } | ||
+ | ===Important=== | ||
+ | * There can only be one '''onloadfunc''' on the page. If there are multiple onloadfunc functions defined the system will only run one of them. | ||
+ | If you have an '''onloadfunc''' on multiple different User [[Role]]s then if a contact happens to have 2 roles that both have a Custom Field with '''onloadfunc''' defined you will run into this issue. | ||
+ | This can be avoided by creating an [[Browser Script]] Custom Field that is visible for all contacts using the '''User Custom Fields''' and/or '''Contact Custom Fields''' on [[Global Settings]. That [[Browser Script]] custom field can have the '''onloadfunc''' that will be visible for all users, that will look for other functions defined on various roles to be called: | ||
+ | |||
+ | |||
+ | <pre> | ||
+ | function onloadfunc{}( | ||
+ | if(window.employeeOnloadfunc) //check if there is a function on the page called employeeOnloadfunc | ||
+ | employeeOnloadfunc(); //call the function if present. | ||
+ | if(window.applicantOnloadfunc) //check if there is a function on the page called applicantOnloadfunc | ||
+ | applicantOnloadfunc(); //call the function if present. | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | The on the employee role and applicant role create [[Browser Script]] fields with those functions. They will be called in turn by the main onloadfunc that the system calls automatically. | ||
Revision as of 13:51, 30 April 2013
You can use onloadfunc to create a custom Browser Script that runs whenever a record is first opened.
- This is in place in the UTA at Level 1, Level 2, Level 3 and Invoicing, as well as on Contacts and Accounts
- It only runs in Edit mode at Level 1, Contacts and Accounts, not in view mode.
Instructions:
- Create a Custom Field on the page of type: Custom Field Type: Special – Browser Script
- Include a function in the Browser Script called onloadfunc that includes the JavaScript you wish to execute when the record first opens.
Syntax:
function onloadfunc() { do this RunAnotherFunction() do that }
Important
- There can only be one onloadfunc on the page. If there are multiple onloadfunc functions defined the system will only run one of them.
If you have an onloadfunc on multiple different User Roles then if a contact happens to have 2 roles that both have a Custom Field with onloadfunc defined you will run into this issue. This can be avoided by creating an Browser Script Custom Field that is visible for all contacts using the User Custom Fields and/or Contact Custom Fields on [[Global Settings]. That Browser Script custom field can have the onloadfunc that will be visible for all users, that will look for other functions defined on various roles to be called:
function onloadfunc{}( if(window.employeeOnloadfunc) //check if there is a function on the page called employeeOnloadfunc employeeOnloadfunc(); //call the function if present. if(window.applicantOnloadfunc) //check if there is a function on the page called applicantOnloadfunc applicantOnloadfunc(); //call the function if present. }
The on the employee role and applicant role create Browser Script fields with those functions. They will be called in turn by the main onloadfunc that the system calls automatically.