cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vargas
Advocate I
Advocate I

Button that redirects and records

Hello All,

 

I've got the Question from on of our Members if we could have a Button that redirects and Records the amount of being clicked.

 

The Idea behind this is that they are currently creating an SPO Site and want to have a Button that redirects to another Site Collection which can be easily done with SPO Web Parts, but they'd also would like to know if the same Button could also be used to record the amount of times it has been used, preferably sorted by Day.

 

As I don't believe SPO Web Parts can do this I am looking into Power Apps and building a Button from there but I am not sure if it is possible for a Button to have multiple Functions or not.

 

If anyone has any Suggestions or this isn't possible at all please let me know.

2 ACCEPTED SOLUTIONS

Accepted Solutions
RusselThomas
Microsoft
Microsoft

Hi @Vargas ,

Yes, a button can have as many functions as you want it to have.

Depending on your regional settings, you just need to add either a ; or a ;; at the end of each expression.

For example, with US regional settings, you can set the button OnSelect: property to;

Launch("https://someotherwebsite.com");
Patch(mySPOCounterList, Defaults(mySPOCounterList), {Title: User().Email});

The first expression here will launch another website in a new tab, the second will capture the event into an imaginary SPO list.  If you create this list and connect your app to it, you can later use PBI (or something else) to get a count of all values and see who clicked it and when. 

If you just want a running total of clicks and are not interested in who clicked it when, you can instead just update a single record instead of creating a new record for each click.

 

Hope this helps,

 

RT

View solution in original post

v-jefferni
Community Support
Community Support

Hi @Vargas ,

 

Button's OnSelect could definitely include multiple behavior functions, such as in Meeting Capture template App:

216.png

 

The question now would be:

In which way you would like to store the total times of clicking the button in a single day? Could it be stored in a single list within the current SPO site?

 

With above scenario, I made a test and found it is feasible:

1\ In SP site, create a new list say "Daily total clicking", includes columns of Title, Total Clicking ( Number type, default value set to 0)

2\ In Power Apps, set OnSelect to:

 

Launch(....);
If(
    IsBlank(
        LookUp(
            'Daily total clicking',
            Title = Text(
                Today(),
                DateTimeFormat.ShortDate
            )
        )
    ),
    Patch(
        'Daily total clicking',
        Defaults('Daily total clicking'),
        {
            Title: Today(),
            'Total Clicking': 1
        }
    ),
    Patch(
        'Daily total clicking',
        LookUp(
            'Daily total clicking',
            Title = Text(
                Today(),
                DateTimeFormat.ShortDate
            )
        ),
        {
            'Total Clicking': LookUp(
                'Daily total clicking',
                Title = Text(
                    Today(),
                    DateTimeFormat.ShortDate
                )
            ).'Total Clicking' + 1
        }
    )
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

3 REPLIES 3
RusselThomas
Microsoft
Microsoft

Hi @Vargas ,

Yes, a button can have as many functions as you want it to have.

Depending on your regional settings, you just need to add either a ; or a ;; at the end of each expression.

For example, with US regional settings, you can set the button OnSelect: property to;

Launch("https://someotherwebsite.com");
Patch(mySPOCounterList, Defaults(mySPOCounterList), {Title: User().Email});

The first expression here will launch another website in a new tab, the second will capture the event into an imaginary SPO list.  If you create this list and connect your app to it, you can later use PBI (or something else) to get a count of all values and see who clicked it and when. 

If you just want a running total of clicks and are not interested in who clicked it when, you can instead just update a single record instead of creating a new record for each click.

 

Hope this helps,

 

RT

View solution in original post

v-jefferni
Community Support
Community Support

Hi @Vargas ,

 

Button's OnSelect could definitely include multiple behavior functions, such as in Meeting Capture template App:

216.png

 

The question now would be:

In which way you would like to store the total times of clicking the button in a single day? Could it be stored in a single list within the current SPO site?

 

With above scenario, I made a test and found it is feasible:

1\ In SP site, create a new list say "Daily total clicking", includes columns of Title, Total Clicking ( Number type, default value set to 0)

2\ In Power Apps, set OnSelect to:

 

Launch(....);
If(
    IsBlank(
        LookUp(
            'Daily total clicking',
            Title = Text(
                Today(),
                DateTimeFormat.ShortDate
            )
        )
    ),
    Patch(
        'Daily total clicking',
        Defaults('Daily total clicking'),
        {
            Title: Today(),
            'Total Clicking': 1
        }
    ),
    Patch(
        'Daily total clicking',
        LookUp(
            'Daily total clicking',
            Title = Text(
                Today(),
                DateTimeFormat.ShortDate
            )
        ),
        {
            'Total Clicking': LookUp(
                'Daily total clicking',
                Title = Text(
                    Today(),
                    DateTimeFormat.ShortDate
                )
            ).'Total Clicking' + 1
        }
    )
)

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

 

View solution in original post

@RusselThomas and @v-jefferni thank you very much for the Information and help.

As I am new to PowerApps your Suggestions helped me a lot and I tried out both Suggestions which worked.

According to our Members I might have to make some changes to them but at least there's a place to start from so thanks a lot to the both of you.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,973)