cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mattpadge24
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
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
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

mattpadge24
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.

 

mattpadge24
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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,667)