Relative path for variables (eg iformbuilder.math.sum) or passing data to parent
As I understand it you always need to use the full "path" name when accessing child variables in a parent or when using built-in functions
eg iformbuilder.math.sum(table_name.subform_element_dcn, 'element_on_subform')
(https://iformbuilder.zendesk.com/hc/en-us/articles/201697610?)
This means that if you copy the parent form or rename it you need to update the javascript for that aggregation.
It's the same for passing data around.
https://iformbuilder.zendesk.com/hc/en-us/articles/201697700-Pass-parent-data-to-subform-subform-to-parent-
It would be much better for reuse and supportability if there was a mechanism to state <current_record> and hence use not explictly state the parent table & path.
eg iformbuilder.math.sum($current_record.subform_element_dcn, 'element_on_subform')
where $current_record is evaluated as the name of the parent table (and any higher level parent records).
Not sure if I've made that clear - or if iFormbuilder or Javascript has a mechanism to do this already.
-
This should work, but I haven't tested extensively. The trick, as best I can tell, is that you have to somehow trigger the JS in the Dynamic Value to run. Without the IF, it won't work. With it, it does. I have to do something similar when I have a function that is dependent on multiple widget values - write an if with a bunch of OR's on all the fields and it tends to work.
Having said that... it doesn't really address the issue raised above since the IF statement still contains a reference to the parent form name... which is what you (and I) were trying to avoid.
Page JS:
function GetValue1(){
return function_main.subf[0].value1;
}Dynamic Value:
if(function_main.subf.length > 0){GetValue1()}
Please sign in to leave a comment.
Comments
6 comments