Skip to main content

Notifications

Power Automate - Using Connectors
Answered

Create new record on MySQL table

(0) ShareShare
ReportReport
Posted on by 21

Hello. Sorry if I'm cross-posting here, but I've been searching and searching all over the forum, and the internet, and I can't find a good solution for doing this. Besides that, I'm very new to Power Automete (Flow), so please forgive me if someone has already posted a solution for this and I couldn't found it.

 

So, basically I'm trying to create a fllow that creates a new record on a MySQL table (connector is working and tested), each time a message is flagged in Outlook. So, I've created a new Flow (Outlook - When a new mail is flagged V3) and then added the action of creating a new row (MySQL Insert Row).

 

As I've read on other forum posts on this forum, for database engines other than MSSQL, I need to create a mandatory Id field, which I was expecting to be automatically filled, as the Id field on the MySQL table is set to INT, Primary Key, Auto Increment ( I can't change this, because the table is part of a self-hosted desktop application.

 

mysql_id.PNG

 

 So, once the Id can't be automatically generated by the flow, how can I get the last Id record from the table and, then, increment by one, using an expression?

 

I've tried using LAST function, based on some suggestions here at the forum, but as I'm a noob with Power Automate, I wasn't able to get it working. Also, I was trying Get Row, but I really can't find a way.

 

Is there anyone who has already have some MySQL new record example working, or Postgres (I think the problem is the same) who can help me here?

 

Thanks in advance.

  • josecardoso Profile Picture
    josecardoso 21 on at
    Re: Create new record on MySQL table

    Many thanks @abm. Perfect, this worked like a charm!

  • Verified answer
    abm abm Profile Picture
    abm abm 32,288 on at
    Re: Create new record on MySQL table

    Hi @josecardoso 

     

    I didn't have MySQL earlier and installed one now. This is what I did to increment the index. Please follow the steps:

    My index id column is called idJobTypes which is an auto increment one.

     

    image.png

     

    Above I did used the Get Rows records top one only order by idJobTypes (Primarykey) desc. This will give you the latest number in the db.

     

    Next iterate the result and store in a variable. Finally increment the identifier value and insert the row values using the latest incremented id. See below.

     

    image.png

     

    The expression I am using above is 

     

    add(variables('Id'),1)
     
    Below is my test result
     
    image.png
     
    If you have any questions please let me know.
     
    Thanks
    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard

Featured topics