cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Make image selectable

Hi there,

 

The below is a popup box which has all the information filtered in. Currently if someone clicks on one of the 4 icons (don't mind them, they're temporary 🙂 ) it automatically files into a sharepoint list and emails me.  It's all working great.

 

Capture.JPG

 

I would however, like to change this so the images are 'selectable'.  So if i click on the monitor, it will grey or something and so on, so then if i highlight two of the images, when i click submit it, it will send me a notification with just the two selected.  

 

I can do this as a checkbox etc.  But would like to keep it 'clean' looking.


Thanks for looking.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: Make image selectable

Hi @Joko ,

 

I ran the code I pasted and it seems fine - the issues are likely in the actions you're performing for each Switch.

It might help to see the actual errors PowerApps is giving you?

 

Just looking at the code you pasted there appear to be a few things that could cause issues - for one, you're just switching a single value but you're ending the line with a comma, meaning the function is expecting another switch condition and not finding it.  You can remove the comma for a start.

......" & CommentBox.Text),

Then, your patch statement is adding a single field and an entire row of blank data for every field you're updating.  I'm assuming the record you want to patch is a single row?  If so, then instead of doing this;

 

Patch(itRoomChecker, Defaults(itRoomChecker), 
       {field: value}, 
       {field: value}, 
       {table: {field: value, field: value}})

you might want to do this;

 

 

Patch(itRoomChecker, Defaults(itRoomChecker), 
       {field: value, field: value, table: {field: value, field: value}})

 

 

Other than that, I'd need to see the errors you're getting to understand more about what other problems you might be encountering.   I'd suggest separating out each action (your patch and sendmail actions), and attaching them individually to a button to test manually before placing them into your formula.  Make sure they work and do what you want them to do, then stick them back into your switch function and test.

 

Kind regards,

 

RT

View solution in original post

4 REPLIES 4
Highlighted
Microsoft
Microsoft

Re: Make image selectable

Hi @Joko ,

 

My approach (and this by no measure means it's the right approach or even a good approach - I'm sure someone else could provide something more elegant :)) would be to run a collection with the selections and highlight the images (using background fills or overlays or whatever) based on whether they're in the collection or not.

 

Initialise the collection (screen onVisible is handy for this, you can clear it onHidden as well) - use a button for now to test;

ClearCollect(collectSelectedOptions, 
                    {IconName: "Display", Selected: false}, 
                    {IconName: "Desktop", Selected: false}, 
                    {IconName: "Basket", Selected: false},
                    {IconName: "Whatever", Selected: false})

Then, on each icon, (let's use the Display icon as an example), set the OnSelect: property to;

Patch(
    collectSelectedOptions,
    LookUp(
        collectSelectedOptions,
        IconName = "Display"
    ),
    {
        Selected: !LookUp(
            collectSelectedOptions,
            IconName = "Display",
            Selected
        )
    }
)

This is basically saying, when I select the icon, change the Selected value for that icon in the collection to the opposite of whatever it was before - effectively a toggle.

 

Then you can set the Fill: property of whatever you're using to colour the icon (like a semi-transparent overlay) to;

If(
    LookUp(
        collectSelectedOptions,
        IconName = "Display",
        Selected
    ),
    LightBlue,
    RGBA(0,0,0,0)
)

So it colours the overlay or fill of the icon to LightBlue when it's selected, transparent when it isn't.


Lastly, you can now use the collection to figure what all has been selected - you can ForAll() it or Filter() it or both depending on what it is you're doing whenever the relevant icon Selected field is true.

ForAll(
    Filter(
        collectSelectedOptions,
        Selected
    ),
    Switch(
        IconName,
        "Display",  <do something>,
        "Desktop", <do something>,
        "Basket", <do something>,
        "Whatever", <do something>
    )
)

 

Hope this helps,


RT

 

 

Highlighted
Helper II
Helper II

Re: Make image selectable

First of all, thank you so much for the detailed reply.

 

I have done everything but can't seem to get the function to work.  Am i missing something?

 

ForAll(
    Filter(
        collectSelectedOptions,
        Selected
    ),
    Switch(
        IconName,
        "Display",  Patch(itRoomChecker, Defaults(itRoomChecker), {ItemDamaged: "Monitor"}, {PC: label_computer.Text}, {Room: label_roomnumber.Text}, {Comments: CommentBox.Text }, {StaffMember: User().FullName }, {Period: {Id: Dropdown_Period.Selected.Id, Value: Dropdown_Period.Selected.Value}}); Office365.SendEmail("email@email.co.uk","Damage Report Email","The below damage has just been logged on." & Char(10) & Char(10) & "Staff Member:" & " " & User().FullName & Char(10) & "Room:" & " " & label_roomnumber.Text & Char(10) & "PC:" & " " & label_computer.Text & Char(10) & "Period:" & " " & Dropdown_Period.Selected.Value & Char(10) & "Damage:" & " " & ItemDamaged & "Comment:" & " " & CommentBox.Text),
        
    )
)

Thanks!

Highlighted
Microsoft
Microsoft

Re: Make image selectable

Hi @Joko ,

 

I ran the code I pasted and it seems fine - the issues are likely in the actions you're performing for each Switch.

It might help to see the actual errors PowerApps is giving you?

 

Just looking at the code you pasted there appear to be a few things that could cause issues - for one, you're just switching a single value but you're ending the line with a comma, meaning the function is expecting another switch condition and not finding it.  You can remove the comma for a start.

......" & CommentBox.Text),

Then, your patch statement is adding a single field and an entire row of blank data for every field you're updating.  I'm assuming the record you want to patch is a single row?  If so, then instead of doing this;

 

Patch(itRoomChecker, Defaults(itRoomChecker), 
       {field: value}, 
       {field: value}, 
       {table: {field: value, field: value}})

you might want to do this;

 

 

Patch(itRoomChecker, Defaults(itRoomChecker), 
       {field: value, field: value, table: {field: value, field: value}})

 

 

Other than that, I'd need to see the errors you're getting to understand more about what other problems you might be encountering.   I'd suggest separating out each action (your patch and sendmail actions), and attaching them individually to a button to test manually before placing them into your formula.  Make sure they work and do what you want them to do, then stick them back into your switch function and test.

 

Kind regards,

 

RT

View solution in original post

Highlighted
Helper II
Helper II

Re: Make image selectable

That worked an absolute treat.  Thank you so much for your time.

 

I have remoted the email function for now as something in that was failing it.

 

Thanks again.

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,554)