cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Presenting, Creating and Saving Tags (Mr-Dang Method)

Hello,

I really like the way @mr-dang uses a Combobox to capture tags in his Open House App. This is a powerful way to get metadata from users. I'm having trouble implementing it and hope someone here can assist.

Use Case:

  • All user-entered tags are stored in SQL tagTable
  • OnStart of app, tagTable is collected (colTags)
  • Items property of Combobox is set to colTags
  • User begins typing a tag...
    • If tag exists in colTags, user selects
    • If tag does not exist in colTags, the tag is added to colTags and later written to tagTable

Code:

Screen1:

  • OnStart:
    • ClearCollect(colTags, '[dbo].[tagTable]')

ComboBox1:

  • Items:
    • colTags
  • OnChange:
    • UpdateContext({varTimerStart: !varTimerStart})

Timer1:

  • Start:
    • varTimerStart
  • OnTimerEnd:
    • Set(varTempTags,ComboBox1.SearchText);
      
      Remove(colTags,
          Filter(colTags,
              !(Value exactin ComboBox1.SelectedItems.Value)
          )
      );
      
      ForAll(
          Filter(
              Split(
                  Trim(varTempTags),
              ";"),
              !IsBlank(Result)
          ),
          If(
              !(Result exactin colTags.Value),
              Collect(colTags,Result
              )
          )
      )

Issues:

  • I wasn't able to duplicate @mr-dang's code exactly. The .Value and .Result terms would not work on my end. Also the final Collect statement in his solution is: Collect(colTags, Result:Result). I don't have this option in my app. Not sure where it comes in.
  • Tags that are being written when timer expires are added as partial tags.
  • If tags are cancelled ("x" 'd) the collection is cleared

Does anyone see how this could be fixed/made a bit more user friendly?
Thanks and Happy New Year!

2 REPLIES 2
Highlighted
Power Apps
Power Apps

Re: Presenting, Creating and Saving Tags (Mr-Dang Method)

It looks like I forgot to put in some commenting code in this sample 😮

 

I think I see your discrepancy, and it may have to do with your interpretation here:

Collect(colTags, Result:Result)

Here's a break down of what's going on in the OnTimerEnd.

 

 

Set(varTempTags,ComboBox1.SearchText)

This means, "Store whatever is typed into the combobox to a variable." This is stored to a variable so it is not lost. Comboboxes can clear the entry if you click out so saving it to a variable keeps it safe.

 

 

Remove(colTags,
    Filter(colTags,
        !(Value exactin ComboBox1.SelectedItems.Value)
    )
)

This means, "Remove the tags that the user may have X'ed out." For instance, if I have 3 tags saved and I changed my mind and X'd one out. Since it is no longer in the SelectedItems property of the combobox, I want to remove it from the collection of tags so it isn't part of the tags anymore.

 

 

ForAll(
    Filter(
        Split(
            Trim(varTempTags),
        ";"),
        !IsBlank(Result)
    ),
    If(
        !(Result exactin colTags.Value),
        Collect(colTags,Result
        )
    )
)

This means, "If you were to split up the content typed into the combobox at each instance of a semi-colon and the resulting split up string is not blank, then collect it to the collection colTags."

 

Note that the colTags collections statement does not explicitly say what column and field the Result should be written to. If a column name is not specified, PowerApps creates a default column called "Value."

 

 

Can you check the part in red? I am thinking you may have mistyped it based on your intrepretation:


@seadude wrote:

Issues:

  • I wasn't able to duplicate @mr-dang's code exactly. The .Value and .Result terms would not work on my end. Also the final Collect statement in his solution is: Collect(colTags, Result:Result). I don't have this option in my app. Not sure where it comes in.

 

Highlighted
Super User
Super User

Re: Presenting, Creating and Saving Tags (Mr-Dang Method)

Thanks for your time @Mr-Dang-MSFT. I'll work through this again based on your explanation. I got the "...Result:Results..." piece from the Open House video. PowerApps wouldn't accept "...Result: Result..." on my end.
image.png

Helpful resources

Announcements
secondImage

Return to Workplace

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

secondImage

Super Users Coming in August

We are excited for the next Super User season.

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 (7,236)