cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lardo5150
Microsoft
Microsoft

Change Form Choices, but still submit as original Choice

I have an SPO List (This site was not created by me, but by our SPO team, I can't change these columns).

I have a column called AssignmentDays.

The choices in this this column are 0,1,2,3,4,5,6

The numbers represent the day of the week, starting with Sunday.

 

If I present this form to the end user in the App, they see the numbers:

lardo5150_0-1645979131706.png

 

If this is insanely complicated, then I will just not add this feature.

Here is what I am hoping the end result will be.

 

Instead of presenting the user with the numbers, the choices will actually be the days

Sunday, Monday, Tuesday.....etc.

The user can select multiple choices.

When they submit the form, the NUMBERS are actually submitted to the SPO Column as that is what is required there.

 

So for example, 

instead of being presented with 0,1,2,3,4,5,6

The user is presented with Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

If the user selects Sunday, Monday, Tuesday, Wednesday, then what actually gets submitted back to the SPO List will be 0,1,2,3

 

is this possible?

 

EDIT:  One thing I forgot to add, is this column is already prepopulated with these days.

So if a user currently has 4,5,6 in that column, and they submit 0,1,2,3, then that 4,5,6 is overwritten, and only 0,1,2,3 will be there.

So would we need to clear that column first, or will the form just atuomatically do that?

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@lardo5150 

You did not specifically state this, but I am assuming that the AssignmentDays column is a Choice column that allows multiple selections.  And that the values of that choice column are 0 through 6 based.

 

So, if that is the case...

 

Set the Items property of your Combobox to:

With({_days: Calendar.WeekdaysLong()},
    ForAll(Sequence(7, 0),
        {Day: Last(FirstN(_days, Value + 1)).Value,
        Value: Value
        }
    )
)

Set your Update property on your datacard to:  yourCombobox.SelectedItems.Value

 

Then set the DefaultSelectedItems property of the combobox to:

With({_days: Calendar.WeekdaysLong()},
    ForAll(Parent.Default,
        {Day: Last(FirstN(_days, Value+1)).Value,
        Value: Value
        }
    )
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@lardo5150 

You should not be manually setting anything in the form.  A form will display the underlying record just fine.  If it is not, then either the form is in the wrong mode or the Item property of the form is not producing the record you expect.

 

Your Form should be in Edit mode.  Your Item property should be: 

LookUp(Engineers, StartsWith(UPN, USer().Email))

 

This should be step #1...getting your record to be producing the record you want.

 

Now as far as the form, it appears you have changed a lot of the defaults.  These should all be put back to their default and not changed.  If you have too many, then I would suggest removing the form and adding a new one back in to restore all the defaults.

Things that I see you have changed are things like the DefaultSelectedItems (DSI) property on the Engineer type.  That should be Parent.Default !

 

Setting the record in the OnStart is fine - it would still be a LookUp function, so you can do it in the OnStart or on-demand in any formula.

 

The Working Days should be filled in.  That was my mistake, your DSI formula for that combobox should be:

With({_days: Calendar.WeekdaysLong()},
    ForAll(ThisItem.AssignmentDays,
        {Day: Last(FirstN(_days, Value+1)).Value,
        Value: Value
        }
    )
)

And yes, the days match as you mentioned.

 

Correct all of those things and see where that gets you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
RandyHayes
Super User
Super User

@lardo5150 

You did not specifically state this, but I am assuming that the AssignmentDays column is a Choice column that allows multiple selections.  And that the values of that choice column are 0 through 6 based.

 

So, if that is the case...

 

Set the Items property of your Combobox to:

With({_days: Calendar.WeekdaysLong()},
    ForAll(Sequence(7, 0),
        {Day: Last(FirstN(_days, Value + 1)).Value,
        Value: Value
        }
    )
)

Set your Update property on your datacard to:  yourCombobox.SelectedItems.Value

 

Then set the DefaultSelectedItems property of the combobox to:

With({_days: Calendar.WeekdaysLong()},
    ForAll(Parent.Default,
        {Day: Last(FirstN(_days, Value+1)).Value,
        Value: Value
        }
    )
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes  before I try this, I just noticed something I am trying to understand first.

I have the form set to edit mode.

 

When I am in a different tab, and I click on the button to take me to the screen that has the form, I am not using anything like EditForm or NewForm.

Navigate(QueueTimeChangeScreen, ScreenTransition.None);

When I get to the form, it is not populating what is currently selected.

So, my service account should see the row that has the information related to this specific user.

I have a variable that is set when the app opens:

Set(var_engineer,LookUp(Engineers, UPN=User().Email));

I set the variable as the Items on the form. 

I was expecting the fields to show preopulated with what is set in SPO, but it is not.

I can also still select other engineers.

 

What I was expecting is that all the fields be filled in already, along with AssignmentDays and AssignmentHours.

But it is not doing that.

So, is that by design?

If so, if we choose different assignment days, when we do submit it will change what is currently there correct?

On this screen, I only want the current user to see their corresponding row in SPO.

 

lardo5150_1-1645989856899.png

Once I get an understanding on that, I can start testing out your suggestion.

 

lardo5150
Microsoft
Microsoft

I even changed the Item of the form to a lookup of the specific engineer.  same result

lardo5150
Microsoft
Microsoft

Couple of things here @RandyHayes 

I was able to get Title and EngineerType to default to the current user.

I made Title a View only (as I dont want them to change it).  I just wanted it there to show the current user.

One thing though, even though I made the form items the current user, it does not populate the fields.  I had to manually change those fields.

lardo5150_4-1645991906392.png

lardo5150_5-1645991946875.png

 

I left EngineerType as editable just in case they change roles in the future they can change that.

I also prepoulated it with a variable that I set at the onstart of the app instead of using a lookup (was just testing the variable, I can make it all the same later).

 

For Working Days, I was expecting the choices to automatically be filled in.  

If that is not the case, that is fine.

I set this up per your instructions. 

 

lardo5150_6-1645992074631.png

 

 

lardo5150_7-1645992104338.png

 

 

I am getting an error though on the datacard for defaultselectedItems

 

lardo5150_8-1645992152777.pnglardo5150_9-1645992173142.png

 

Couple of questions here real quick.

Even though I set the forms items to a specific engineer, it does not prepopulate the items.

if that is by design, I just want to make sure that the item I will update in SPO, is the correct one.

Also, I am trying to figure out your code.

Are we matching zero to Sunday, 1 to Monday, 2, to Tuesday, etc....?

 

 

 

 

 

 

RandyHayes
Super User
Super User

@lardo5150 

You should not be manually setting anything in the form.  A form will display the underlying record just fine.  If it is not, then either the form is in the wrong mode or the Item property of the form is not producing the record you expect.

 

Your Form should be in Edit mode.  Your Item property should be: 

LookUp(Engineers, StartsWith(UPN, USer().Email))

 

This should be step #1...getting your record to be producing the record you want.

 

Now as far as the form, it appears you have changed a lot of the defaults.  These should all be put back to their default and not changed.  If you have too many, then I would suggest removing the form and adding a new one back in to restore all the defaults.

Things that I see you have changed are things like the DefaultSelectedItems (DSI) property on the Engineer type.  That should be Parent.Default !

 

Setting the record in the OnStart is fine - it would still be a LookUp function, so you can do it in the OnStart or on-demand in any formula.

 

The Working Days should be filled in.  That was my mistake, your DSI formula for that combobox should be:

With({_days: Calendar.WeekdaysLong()},
    ForAll(ThisItem.AssignmentDays,
        {Day: Last(FirstN(_days, Value+1)).Value,
        Value: Value
        }
    )
)

And yes, the days match as you mentioned.

 

Correct all of those things and see where that gets you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
lardo5150
Microsoft
Microsoft

I told my wife, I need to find out where randy lives, fly out there and buy him dinner.

Thanks man!!

So, I must have been screwing around so much, I just removed the form and populated the Item..BOOM, it all showed up. 

And the code you sent is now working!

So awesome.  going to play with this a bit.

THANK YOU AGAIN!

I am going to start a new thread tomorrow, as the assignment times will be similar, but with timezones 🙂

RandyHayes
Super User
Super User

@lardo5150 

LOL!  Always welcome to make a trip! 😁

Glad it worked out.

It's not uncommon that one makes some changes that don't seem to resolve what is expected, then more, then more and before you know it, things are too wacky to turn around.  So, best to scratch and restart - as you saw!

 

Sounds good on the next post.  I'll keep any eye out for it!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,659)