cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Check if not required fields are used

Hi 

 

I have a PCF with a few properties, and not all properties are required. 
Depending wheter the properties are set to a CRM-field or not, i want to have different behaviour in my code. 

Is this somehow possible? 

For example by checking the value if it's undefined or something alike? 

 

Kind regards! 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Visitor

Re: Check if not required fields are used

I looked further into it and found the following: 

 

  • A non-required field that is configured in crm to a field, returns in the componentframeworkcontext the following : 
    context.parameters.<myconfiguredproperty>.type  = SingleLine.Text (or to what type of field you configured it was configured)
  • context.parameters.<mynotconfiguredproperty>.type = null 

Can someone confirm this will always be the case? 

 

 

 

View solution in original post

5 REPLIES 5
Highlighted
Solution Sage
Solution Sage

Re: Check if not required fields are used

That is exactly how most of our PCF controls work.

 

Each PCF control has to have a single bound field but you can add as many other fields as you want as either bound (has to be an attribute) or input (can be either an attribute field or a design time value*) fields. So all our backend business logic (which used to be 1,000s of lines of complex Javascript) are now made up of the appropriate PCF components which will consist of 1 editable fields (for instance trigger attributes) and secondary input or bound field say "Select Entity" which will be displayed higher up the form (in the case of Select Entity it's usually at the top).

 

The other thing to note is that apart from the first main parameter the PowerApp form will not be aware that secondary values need to be loaded unless you explicitly add those secondary parameters as fields on the form. The attributes can be hidden fields on the form but they do need to there as otherwise the form's lazy loading logic will not request the values and will just pass null or empty values to your components.

 

* text fields are limited to 100 characters at the moment but the bound value can be far larger than that. 

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".
Highlighted
Frequent Visitor

Re: Check if not required fields are used

@ben-thompsonThanks for answerring! But I'm afraid you didn't really understand my question...
I know there's the possibility to add extra parameters that are not required. 
The thing I want to find out in code is; if those extra, not required, fields were bound to a crm field when the control was added to the main field or not. 

Because there's the possibility to leave those extra fields unused. 


Highlighted
Solution Sage
Solution Sage

Re: Check if not required fields are used

snip - as unhelpful

---
If this post has answered your question please consider it for "Accept as Solution" or if it has been helpful give it a "Thumbs Up".
Highlighted
Frequent Visitor

Re: Check if not required fields are used

I looked further into it and found the following: 

 

  • A non-required field that is configured in crm to a field, returns in the componentframeworkcontext the following : 
    context.parameters.<myconfiguredproperty>.type  = SingleLine.Text (or to what type of field you configured it was configured)
  • context.parameters.<mynotconfiguredproperty>.type = null 

Can someone confirm this will always be the case? 

 

 

 

View solution in original post

Highlighted
Super User
Super User

Re: Check if not required fields are used

Hi @FredericTerryn , 

The way you've found out seems to work. Since the value (raw) "null" doesn't tell if the customizer set the property or not,  I am not aware of another way to implement your requirement, but this could work by hazard for now, you're right.

 

In my components I don't rely on the fact that the customizer set an extra property or not. I prefer to define another property of type "Enum", where the customized defines how the control should work. 

For instance, the control for a metadata autocomplete, lets the user decide if he/she wants it to perform as an "Entity" or an "Attribute" autocomplete. If it's an "Attribute", then I consider the parameter "entityName".

Maybe you know about this already, but in case it helps you design your component, here is the definition of the properties in my  manifest:

<property name="controlValue" ... of-type="SingleLine.Text" usage="bound" required="true" />
<property name="behavior" ... of-type="Enum" usage="input" required="true">
      <value name="Entity" display-name-key="Entity" description-key="Entity names" default="true">Entity</value>
      <value name="Attribute" display-name-key="Attribute" description-key="Attributes for an entity" >Attribute</value>
</property>
<property name="entityName" ... of-type="SingleLine.Text" usage="input" required="false" />  

 Best regards,

Diana

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Users online (5,889)