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

How do I change bordercolor on a control, if it has no data when a user submits data?

I am trying to validate that certain fields contain data before sending the data to my SharePoint list. Right now I am doing something like this...

If(
    !IsBlank(TxtInput_1.Text, Set(BorderColor, Red), Set(BorderColor, Black)) && !IsBlank(DropDwn_1.Selected.Value.Text, Set(BorderColor, Red), Set(BorderColor, Black)) && !IsBlank(radioBtn_1.Selected.Value, Set(BorderColor, Red), Set(BorderColor, Black))
    Patch(
        MyList_1,
        Defaults(MyList_1),
        {
		
		}
	)
)

but this is giving me errors that state that there are some invalid arhuments. What is the best way to go about doing this?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Spawn10 ,

If you use this formula, whether the field is blank will not effect the patch operation.

It only effect the border color.

Regardless the field is blank or not , the patch function will perform.

Do you want that if any field is blank, the patch operation will not perform?

 

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Drrickryp
Super User
Super User

Hi @Spawn10 ,

In the BorderColor property of each control that you wanted to highlight, you would put the following formula

If(!IsBlank(DataCardValue16.Text),Black, Color.Red)

Once you submit the form, it won't matter what the border color is.  If you want to prevent the user from submitting the form unless the field has data, then set the Required property of the card containing those particular controls to true.  That will change the border properties, prevent the form from being submitted and show an error message.

v-yutliu-msft
Community Support
Community Support

Hi @Spawn10 ,

Do you want that: if all the fields are not null, the border color is black; if any field are null, the border color is red?

I suggest you try this formula: ( the border color is not related with patch function.)

If(
    !IsBlank(TxtInput_1.Text)&&!IsBlank(DropDwn_1.Selected.Value.Text)&& !IsBlank(radioBtn_1.Selected.Value),
Set(BorderColor, Black),
Set(BorderColor, Red)
); Patch( MyList_1, Defaults(MyList_1), {....,.....,..... } )

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thank you for the help v-yutliu-msft.

I just have one question...using it this way, won't the patch operation still be executed even if one of the fields is blank?

 

Hi @Spawn10 ,

If you use this formula, whether the field is blank will not effect the patch operation.

It only effect the border color.

Regardless the field is blank or not , the patch function will perform.

Do you want that if any field is blank, the patch operation will not perform?

 

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes I didn't want the patch to perform, if those fields were blank. I ended up using this syntax and it served my purpose....

If(
    IsBlank(TxtInput_1.Text) || IsBlank(DropDwn_1.Selected.Value.Text) || IsBlank(radioBtn_1.Selected.Value),
     Set(BorderColor, Red),
	 Patch(
        MyList_1,
        Defaults(MyList_1),
        {....,.....,.....
	}
     )
   );

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,011)