cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EMARIN91
Level: Powered On

Save a Collection via MS Flow to a SQL Server Table

Hi everyone,
I have a Collection with 03 columns. What I need is to be able to send the collection to a Table in SQL Server (which I already have elaborated). I want to do this using a button via FLOW and not with the Patch function. So far I have read that Flow does not manage sending tables, only strings. It would be so kind to share a diagram of the flow and formulas for a possible solution.

Collection.PNGSQL Table.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Save a Collection via MS Flow to a SQL Server Table

Hi @EMARIN91 

 

As we have a limitation to only pass strings/numbers from powerapps to flow, you can convert your collection in the form of string, each row sepeared by a comma and each column, seperated by colon. Please the below expression for doing so:
Powerapps button action to flow:
'PowerAppsbutton-1'.Run(Concat(mylocalcollection,IdLlanta&":"&Milimitro&":"&Presion&","))
Here, mylocalcollection is the name of my collection and IDLlanta/Milimitro/Presion are the columns, please replace with respective values. This separates the columns by ':' and row by ','.
Now comes the flow,
 
1) Initialize a variable, for storing the value passed by powerapps. this should be of type string.
    Expression: 
substring(triggerBody()['Initializevariable_Value'],0,sub(length(triggerBody()['Initializevariable_Value']),1))
This will remove the trailing comma.
Also, if triggerBody()['Initializevariable_Value'] is not accepted, please go to dynamic content and select Ask in Powerapps so that a new variable is created which needs to be passed as parameter.
 
2) Initialize another variable(CollectionRows) of type array to store all the rows inside it.
    Expression: 
split(variables('inputstring'),',')
Here, please replace inputstring with the name of variable created in Step 1.
    
3) Now create a Apply to each loop, to iterate over every record:
    Output from Previous Step: Select CollectionRows.
    
4) Inside Apply to each add action to insert row and pass the expression in each of the columns as:
    IdLlanta: split(items('Apply_to_each'),':')[0]
    Milimitro: split(items('Apply_to_each'),':')[1]
    Presion: split(items('Apply_to_each'),':')[2]
MicrosoftTeams-image (123).png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
2 REPLIES 2
Highlighted
Super User
Super User

Re: Save a Collection via MS Flow to a SQL Server Table

Hi @EMARIN91 

 

As we have a limitation to only pass strings/numbers from powerapps to flow, you can convert your collection in the form of string, each row sepeared by a comma and each column, seperated by colon. Please the below expression for doing so:
Powerapps button action to flow:
'PowerAppsbutton-1'.Run(Concat(mylocalcollection,IdLlanta&":"&Milimitro&":"&Presion&","))
Here, mylocalcollection is the name of my collection and IDLlanta/Milimitro/Presion are the columns, please replace with respective values. This separates the columns by ':' and row by ','.
Now comes the flow,
 
1) Initialize a variable, for storing the value passed by powerapps. this should be of type string.
    Expression: 
substring(triggerBody()['Initializevariable_Value'],0,sub(length(triggerBody()['Initializevariable_Value']),1))
This will remove the trailing comma.
Also, if triggerBody()['Initializevariable_Value'] is not accepted, please go to dynamic content and select Ask in Powerapps so that a new variable is created which needs to be passed as parameter.
 
2) Initialize another variable(CollectionRows) of type array to store all the rows inside it.
    Expression: 
split(variables('inputstring'),',')
Here, please replace inputstring with the name of variable created in Step 1.
    
3) Now create a Apply to each loop, to iterate over every record:
    Output from Previous Step: Select CollectionRows.
    
4) Inside Apply to each add action to insert row and pass the expression in each of the columns as:
    IdLlanta: split(items('Apply_to_each'),':')[0]
    Milimitro: split(items('Apply_to_each'),':')[1]
    Presion: split(items('Apply_to_each'),':')[2]
MicrosoftTeams-image (123).png

 

Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
EMARIN91
Level: Powered On

Re: Save a Collection via MS Flow to a SQL Server Table

You are a genius, thank you very much.

The codes in the Flow were very helpful.