Forum Discussion
Fracturedscot
Nov 11, 2022Copper Contributor
Capture who uses or copies a Form Template
I am looking to set up a company resource page with a number of standardised forms people can copy and use for their own purposes. I have looked at using the Template link in the share tab of forms ...
RobElliott
Nov 11, 2022Silver Contributor
Fracturedscot There is nothing in Forms itself that tracks this and there are also no actions or triggers in Power Automate that can do this.
But what you could do is to have a list in SharePoint which lists the forms and has a JSON-formatted button next to each one which triggers a flow in Power Automate that gets the details of which form it is the user wants and who they are. You would need to give your users a link to this list but bear in mind you can't embed it in a SharePoint page due to the JSON button which won't run from a web part. The flow sends the user an email with a link to the template and uploads the details to a "FormTemplatesSent" list. It can't check whether they actually did duplicate it but it gets you much closer and gives you a way to follow up with them.
So the list of form templates looks like this. The Get Template Link column is a single line of text column and I'll give you the JSON code for formatting it later in the post.
When the button is pressed a panel opens with the template they have requested and a go button to start the flow that sends tehm the email.
The flow looks like this, with a for a selected item trigger and then the first action is to get the item, selecting ID from the dynamic content box that appears when you click in the field.
We then add a get user profile (v2) action to get the details of the user who triggered the flow. And we add a compose action to get the department the user is in.
Next, add a switch control which is a type of condition that just looks at one thing and is based on is equal to.
So if the Title from the FormTemplates list equals Aircraft Service then create an item in the Form TemplateSent list. You then add a Send an email (v2) action to send an email to the user with the link to the tempate.
You would copy the actions to your clipboard then paste them in, changing the link to the template, for the other switch cases. You can have up to 25 cases in any switch.
The resulting email looks like this:
And the ForTemplatesSent list has had the item added to it:
For the button you need to format the single line of text column in advanced mode and add the following JSON, changing the id to the ID of your flow:
JSON format code:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "button",
"txtContent": "Get template link by email",
"customRowAction": {
"action": "executeFlow",
"actionParams": "='{\"id\":\"dd92571b-ce5e-49e9-8379-94f1ad176204\", \"headerText\":\" ' + [$Title] + '\",\"runFlowButtonText\":\"Go\"}'"
},
"style": {
"background-color": "#cf000f",
"color": "white",
"border-radius": "10px"
}
}
I hope that gives you something to think about and try.
Rob
Los Gallardos
Microsoft Power Automate Community Super User
- JuliaDrowatzkyJul 10, 2024Copper Contributor
Thanks for your very good description!
I have a question concerning that part of your post: "For the button you need to format the single line of text column in advanced mode and add the following JSON, changing the id to the ID of your flow: "
I did not get that part. Do I add column of type "single line of text"? And then I add an element to that list where the text ist the JSON code?
When I do this it tells me, that the number of charachters is limited to 255.
- Rob_ElliottJul 10, 2024Bronze Contributor
JuliaDrowatzky you add a single line of text column to your list. You then go to Column Settings -> Format this column:
Click the advanced mode link...
...and paste the JSON in and click the Save button.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)