I would like to be able to populate custom drops through code instead of needing the user to provide input explicitly.
i.e., I would like to assign a value to a custom drop programmatorically, e.g.
It’s not possible to save a value in the database based on a computation. What would you like to use this for? There might be other ways to accomplish the end goal.
We would like to use this to compute values once and store them for later usage (in other templates), so we do not need to duplicate the code performing the computations in multiple templates.
Also, we would like to initiate some input fields through code to some computed values, so a dynamic value is filled in before the user provides input. I know this second goal can be accomplished by capturing/assigning a variable and setting it as default for the input, but that value is then not available in other templates either, since the custom drop does not actually save the default value for that input but stays ‘blank’ until input is explicitly saved, so we would again need to duplicate the code performing the computations everywhere we need the dynamic values to be displayed.
I see that the API allows to populate the custom drops for company, company.people as well as period.reconciliation, (not for period-drops). So it is possible to calculate and save a value in these custom drops from my own software through the API, but not from a template script?
You can actually compute values and put them in a ‘result’, this means that it can be used in other templates (see the result tag at the bottom of the page https://github.com/GetSilverfin/sf-templates (we use this for example in the template ‘verworpen uitgaven’ to expose that to the ‘belastingsberekening’).
I think with the result tag you should be able to do what you want (but you can’t have circular references).
When you fill in a value with the API, the action is more similar to someone typing something in the browser, then a template calculating something.
This can indeed help me to exchange computed values from a reconciliation template to a different template.
Is it also possible to save values with a result-tag in Text templates?