// 1. Put everything into a list
ClearCollect(
InputList,
ForAll(
FormQuestions.AllItems As Row,
If(
Row.FieldType.Value = "Choice",
// Specialcase: Choice/Checkbox
{
// Look for the part in the Mapping after the ":" for example Yes:CheckboxInWordYes;No:CheckboxInWordNo
Key: LookUp(
Split(Row.Optionsmapping, ";"),
StartsWith(Value, Row.SelectChoice.Selected.Value & ":"),
Mid(Value, Len(Row.SelectChoice.Selected.Value) + 2)
),
Value: "true"
},
// Normal Case: Date or Text
{
Key: Row.FieldName,
Value: If(
Row.FieldType.Value = "Date",
Text(Row.SelectDate.SelectedDate, "yyyy-MM-dd"),
Row.InputText.Text
)
}
)
)
);
// 2. Make list a flat JSON : {"Field": "Value", "Feld2": "Value2"}
UpdateContext({
FinalJson: "{" &
Concat(InputList, Char(34) & Key & Char(34) & ":" & If(Value = "true" || Value = "false", Lower(Value), Char(34) & Value & Char(34)), ",") &
"}"
});
// 3. Start Flow and save result (PDF)
UpdateContext({
PreviewFile: "data:application/pdf;base64," & CreatePDFPreview.Run(SelectedForm, FinalJson).pdfcontent
})
All the questions are in a gallery, there is a seperate list with every question of every form. A column has the form so the items of the gallery is just every question that has the selected form as it's form. It also has it's type (text,date,choice) and If it's a choice it has it's options and what checkbox they are mapped to. Here is an example in the power app:

I simply cannot get it to fill the Template. If something is unclear, what is probably the case, please let me know. 🙏