Search code examples
palantir-foundry

How to Prefill a Foundry Form embedded in a Slate document (using handlebars)?


I am trying to prefill a form embedded in a Slate document but without success. The format bellow seems not to work: "prefilledValues": {"uri_name1":"prefilledvalue1","uri_name2":"prefilledvalue1"...} Furthermore, can we use Handlebars to prefill a form? Thank you for your help.


Solution

  • First you have to setup your Form correctly to make it prefillable. Open the form, select an element that you want to prefill and choose "Configure field".

    configure field

    This will open the Properties-panel on the right side of your form. On the bottom of the Properties select "Advanced". Then a field called "UrlParam" will be displayed. This is where you set the parameter name that you will later call in Slate for prefilling. In my example I set it to "Threshold".

    url param

    In Slate, add a Foundry Form-widget and set the Form RID to the RID of your Form. Now you should be able to successfully add a prefilled value using the UrlParam that you set in the Form like this:

    prefilled values

    Now you should see that the embedded Form in Slate is displaying your prefilled value:

    result

    And yes, Handlebars can be used to prefill a form, but it seems like that it only accepts strings. So if you have a numeric value, make sure to convert it to String with the helper-function toString, for example if you have a variable called v_test with a value of 4:

    prefilled values with handlebars

    That should lead to this result:

    result with handlebars