Custom Embedded JavaScript Functions: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 6: Line 6:


* To obtain a photo of the currently viewing user using their integrated camera and then embed it in the document
* To obtain a photo of the currently viewing user using their integrated camera and then embed it in the document
* To connect via REST API to an external service to fetch additional data for the contextual record (TODO: Add reference to contexts & handling)
* To connect via REST API to an external service to fetch additional data for the [[Document Contexts|contextual record]]
* To import an external library and display custom elements/components that are rendered by the external library (say a table, chart, image slider etc)
* To import an external library and display custom elements/components that are rendered by the external library (say a table, chart, image slider etc)
* To patch-fix a bug in 3B Docs  
* To patch-fix a bug in 3B Docs  
Line 28: Line 28:
Just like [[Custom Value Formatting|custom value formatters]], when you create a Function Expression, you are basically creating a JavaScript function. This JavaScript function has access to the global context and thus to the [[Current User Navigator Object|user’s navigator object]], the application variables & collections and much more.
Just like [[Custom Value Formatting|custom value formatters]], when you create a Function Expression, you are basically creating a JavaScript function. This JavaScript function has access to the global context and thus to the [[Current User Navigator Object|user’s navigator object]], the application variables & collections and much more.


The difference between [[Custom Value Formatting|custom value formatters]] and Function Expressions lies in the fact that [[Custom Value Formatting|custom value formatters]] can only be applied to a specific [[Merge Fields and Tags|merge tag]], whereas [[Custom Embedded JavaScript Functions|Function Expressions]] form their own independent [[Merge Fields and Tags|merge tags]].
The difference between [[Custom Value Formatting|custom value formatters]] and Function Expressions lies in the fact that [[Custom Value Formatting|custom value formatters]] can only be applied to a specific [[Merge Fields and Tags|merge tag]], whereas [[Custom Embedded JavaScript Functions|Function Expressions]] form their own independent [[Merge Fields and Tags|merge tags]].  


You must always return a string value – this return value will be your “transformation” of the [[Merge Fields and Tags|merge tag]].  
Furthermore, here are a few considerations:
 
* You must always return a string value – this return value will be your “transformation” of the [[Merge Fields and Tags|merge tag]].
* You can access the element that will be inserted into the body of the document via the "element" variable that will be passed to your custom function


== Examples ==
== Examples ==

Navigation menu