Home > database >  PowerApps application development (custom code)
PowerApps application development (custom code)

Time:03-22

I have traditionally built applications in C# and .net framework, but I am looking to move to Power Apps.

I'm need to write a script that takes some information from table1 and copies it to table2 on a button press.

Traditionally I would have written this in C# using a SQL dB connector.

How would I achieve the same thing using PowerApps and a Dataverse?

CodePudding user response:

You can use Power Automate to achieve this : you can run a flow from a button press within PowerApps, here's the documentation :

enter image description here

  • Add a Button control to the PowerApps Studio canvas
  • Change the OnSelect property to something like:
  • //This collects records from SQL_TABLE_1
    
    ClearCollect(colTable1,
        Filter(SQL_TABLE_1,        //This is your SELECT clause
            <column> = <criteria>  //This is your WHERE clause
        )
    );
    
    //This patches records into SQL_TABLE_2
    
    ForAll(colTable1,
        Patch(SQL_TABLE_2,
            Defaults(SQL_TABLE_2),
            {
               <column1_in_colTable1>: <column1_in_sqltable2>,  //"< >" = actual column names
               <column2_in_colTable1>: <column2_in_sqltable2>,
               <columnN_in_colTable1>: <columnN_in_sqltable2>
            }
        )
    )
        
    
    • Related