cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nttdocomo
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

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
Nttdocomo
Frequent Visitor

I encountered an error using this code?

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Users online (1,985)