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:
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?
Solved! Go to Solution.
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.
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.
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.
@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.
Once I get an understanding on that, I can start testing out your suggestion.
I even changed the Item of the form to a lookup of the specific engineer. same result
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.
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.
I am getting an error though on the datacard for defaultselectedItems
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....?
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.
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 🙂
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!
User | Count |
---|---|
126 | |
87 | |
85 | |
75 | |
69 |
User | Count |
---|---|
215 | |
180 | |
139 | |
97 | |
83 |