cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

SQL triggers alternative for powerapps

hi, I have an app where I want the database to log the time it was used, what parts of the app was used etc so I can use power bi to do some analytics (im aware PowerApps has built in analytics but im a student and my lecturer told me I need to do my own) as PowerApps doesn't allow triggers to be used is there an alternative?

 

thanks,

 

mattSQ

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: SQL triggers alternative for powerapps

@mattpadge24 

Create a very simple datasource called ActivityLog using your preferred connector (examples: SharePoint, SQL, CDS).

 

Make a new table and ensure there are at least 3 columns.

  • ID (autonumber)
  • Activity (single line text)
  • ActvityDateTime (date & time)

 

Then anytime you want to record some activity in the app use this code.  It must be placed in a property starting with the word On (examples: OnSelect, OnVisible, OnStart).  Be sure to change the Activity field to your own value.

Patch(
    your_datasource_name,
    Defaults(your_datasource_name),
    {
        Activity: "some text here",
        ActivityDateTime: Now()
    }
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: SQL triggers alternative for powerapps

@mattpadge24 

Create a very simple datasource called ActivityLog using your preferred connector (examples: SharePoint, SQL, CDS).

 

Make a new table and ensure there are at least 3 columns.

  • ID (autonumber)
  • Activity (single line text)
  • ActvityDateTime (date & time)

 

Then anytime you want to record some activity in the app use this code.  It must be placed in a property starting with the word On (examples: OnSelect, OnVisible, OnStart).  Be sure to change the Activity field to your own value.

Patch(
    your_datasource_name,
    Defaults(your_datasource_name),
    {
        Activity: "some text here",
        ActivityDateTime: Now()
    }
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Highlighted
Regular Visitor

Re: SQL triggers alternative for powerapps

hi thanks for your help. so just to clear a few things up would it be:

 

Patch( SQL, Defaults

(your_datasource_name), <---- does this mean the name of the table in SQL?

{ Activity: "sucessfully completed job application", ActivityDateTime: Now() }


)

Highlighted
Super User
Super User

Re: SQL triggers alternative for powerapps

@mattpadge24 

Yes, your_datasource_name does mean the name of your SQL table.

 

Highlighted
Regular Visitor

Re: SQL triggers alternative for powerapps

@mdevaney hi I know its been a while but ive been trying your solution and It isn't working I just want to make sure ive done it right. ive created the table activity log like you said with the columns ID, Activity and ActivityDateTime in Sql and ive attached an image of the code in powerapps... could you take a look to see if its all correct?

thanks

 

 

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,442)