Hello @tilou,
The solution is really simple, and there are multiple alternatives.
– First alternative, defining the equation into the same equation. Assuming that the number field is the fieldname1, the equation associated to the calculated field would be similar to:
(function(){
function fibonacci(num) {
if (num <= 1) return 1;
return fibonacci(num - 1) + fibonacci(num - 2);
}
return fibonacci(fieldname1);
})()
– Second alternative, defining the function globally, and calling it from multiple equations:
* Insert a “HTML Content” field with a piece of code similar to the following one as its content:
<script>
window['fibonacci'] = function(num) {
if (num <= 1) return 1;
return fibonacci(num - 1) + fibonacci(num - 2);
};
</script>
* Now the equation associated to the calculated field would be simply:
fibonacci(fieldname1)
and that’s all.
I’m sorry, but the support service does not cover the implementation of the users’ projects (forms or formulas). If you need help implementing features that are specific to your project, I can offer you a custom coding service:
https://cff.dwbooster.com/customization
Best regards.