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 II
Super User II

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.

View solution in original post

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (2,202)