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

content Get field names and items

Is there a way to get these two contents in the CLI?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: content Get field names and items

This error is being generated due to TypeScript checking.  The Options property can be undefined so you need to account for that. Here are two possible options for you.

 

This one uses option chaining and the logical operator to set a default value if the property for Options does not exist.

var test: any[] = context.parameters.inputValue.attributes?.Options || [];

The second one allows the variable to be undefined or an array.  You will need to make sure to check the variable to make sure it's not undefined before you use it though.

var test: any[] |  undefined= context.parameters.inputValue.attributes?.Options;
 
I'm actually a little surprised you are not seeing the error before the build in Visual Studio Code. You may want to open your project one folder level higher so that the tsconfig.json file is seen by VS Code.
 
--Rick

View solution in original post

2 REPLIES 2
Highlighted
Frequent Visitor

Re: content Get field names and items

I encountered an error using this code?

Highlighted
Resolver I
Resolver I

Re: content Get field names and items

This error is being generated due to TypeScript checking.  The Options property can be undefined so you need to account for that. Here are two possible options for you.

 

This one uses option chaining and the logical operator to set a default value if the property for Options does not exist.

var test: any[] = context.parameters.inputValue.attributes?.Options || [];

The second one allows the variable to be undefined or an array.  You will need to make sure to check the variable to make sure it's not undefined before you use it though.

var test: any[] |  undefined= context.parameters.inputValue.attributes?.Options;
 
I'm actually a little surprised you are not seeing the error before the build in Visual Studio Code. You may want to open your project one folder level higher so that the tsconfig.json file is seen by VS Code.
 
--Rick

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

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

Users online (4,767)