0

This is one of those questions where it should be obvious, but I can't find the answer.

I am building a Power Apps Canvas application that is tied to a SharePoint Online list. I am using an Edit Form, so I have a Card for each field in my form. I want to make my labels red if the field is required. In the label within the card, how do I dynamically detect whether that SharePoint field is required or not?

Update: Parent.Required (Parent being the Card) SHOULD work, but always returns false. The following code works, but I have to manually insert the field name. In this example, "Location".

DataSourceInfo([@'Usage Log']),DataSourceInfo.Required,"Location")

How do I dynamically determine the field name? Parent.DataField returns "Location", but when I use it in the function:

DataSourceInfo([@'Usage Log']),DataSourceInfo.Required,Parent.DataField)

I get this error:

The Function 'DataSourceInfo' has some invalid arguments.

Argument 'Parent.DataField' is invalid, expected a text literal.

1 Answer 1

1

Each field Card, in a Form control has a Required property.

enter image description here

This is an example of how you can take advantage of this property in a child control within a card:

  1. Click on your control, for example, a label
  2. Select a Visible property and use Parent.Required as a value:

enter image description here

3
  • I tried this. Parent.Required is always No.
    – CigarDoug
    Commented Dec 30, 2022 at 18:31
  • If it's always No - try updating the SharePoint Data source in your Canvas app. Commented Dec 30, 2022 at 18:37
  • I did that. These same fields throw an error if I try to save with the field empty, so I know it's detecting required. Maybe I need to restart Power Apps.
    – CigarDoug
    Commented Dec 30, 2022 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.