Sep 17 2021 01:05 PM
Sep 18 2021 02:08 PM - edited Sep 18 2021 02:30 PM
Hi @katzgroup !
I would usually take a different approach to this, validating the user input before allowing them to submit. See what you think of this idea, and let me know if you'd like to approach it differently:
For this example, I have a variable that holds my Sharepoint list item called varCurrentListItem, and in that list there is a number column called NumberColumn.
First, on my number input field, I have the following code in BorderColor:
If(IsNumeric(Self.Text),RGBA(0, 18, 107, 1),RGBA(255,0,0,1))
This will put a red border around the text field if someone enters a non-numeric value.
Then, on my number input field OnChange event, I have the following:
If(
Or(
And(
!IsBlank(varCurrentListItem.NumberColumn) || !IsEmpty(varCurrentListItem.NumberColumn),
Value(Self.Text) > Value(varCurrentListItem.NumberColumn)
),
And(
IsBlank(varCurrentListItem.NumberColumn) || IsEmpty(varCurrentListItem.NumberColumn),
Value(Self.Text) > 0
)
),
If(
Value(Self.Text) > 0,
UpdateContext({isValid: true})
),
UpdateContext({isValid: false})
)
This checks if the number entered into the text input is:
1. If the SharePoint column is blank/empty,, higher than 0
2. If the SharePoint column is not blank/empty, higher than the value in the column
I Use IsEmpty and IsBlank because I never quite remember which one SharePoint validates against for a blank number column. the "||" is equivalent to "or" and allows us to evaluate against multiple criteria in our if statement.
So now..."isValid" will only be true if we have a valid number that fits our criteria. We can use it to allow someone to click on the "Submit" button. My submit button has the following code in DisplayMode:
If(isValid,DisplayMode.Edit,DisplayMode.Disabled)
This code only enables the button to be clicked if "isValid" is true.
And finally, the OnSelect on my submit button looks like this:
UpdateContext({varShowPopup:true})
So when we click the button (which can only be clicked if our number is already valid), we set varShowPopup to true.
Now I can use varShowPopup to show my popup, placing this in the Visible property of my popup group:
varShowPopup
I've attached a copy of the zipped .msapp file to this post for reference.
Let me know if you need any more assistance around this.
Cheers,
Brendan