@@ -153,7 +153,7 @@ alert(`The current form type is: ${formContext.ui.getFormType()}`);
153153
154154alert ( `The current entity type is: ${ formContext . data . entity . getEntityName ( ) } ` ) ;
155155
156- /// Demonstrate Optionset Value as int in Turbo Forms
156+ /// Demonstrate OptionSet Value as int
157157
158158const optionSetAttribute = formContext . getAttribute < Xrm . Attributes . OptionSetAttribute > ( "statuscode" ) ;
159159if ( optionSetAttribute !== null ) {
@@ -170,6 +170,41 @@ if (optionSetAttribute !== null) {
170170 }
171171}
172172
173+ /// Demonstrate OptionSet Value as enum
174+
175+ enum TestOptionSet {
176+ Option1 = 56666000 ,
177+ Option2 = 56666001 ,
178+ }
179+
180+ const optionSetAttributeEnum = formContext . getAttribute < Xrm . Attributes . OptionSetAttribute < TestOptionSet > > ( "statuscode" ) ;
181+ if ( optionSetAttributeEnum !== null ) {
182+ const optionEnumValue : TestOptionSet | null = optionSetAttributeEnum . getValue ( ) ;
183+ }
184+
185+ /// Demonstrate MultiSelectOptionSet Value as int
186+
187+ const multiSelectOptionSetAttribute = formContext . getAttribute < Xrm . Attributes . MultiSelectOptionSetAttribute > (
188+ "statuscode" ,
189+ ) ;
190+ if ( multiSelectOptionSetAttribute !== null ) {
191+ const multiSelectOptionValue : number = multiSelectOptionSetAttribute . getOptions ( ) [ 0 ] . value ;
192+ }
193+
194+ /// Demonstrate MultiSelectOptionSet Value as enum
195+
196+ enum TestMultiSelectOptionSet {
197+ Option1 = 56666000 ,
198+ Option2 = 56666001 ,
199+ }
200+
201+ const multiSelectOptionSetAttributeEnum = formContext . getAttribute <
202+ Xrm . Attributes . MultiSelectOptionSetAttribute < TestMultiSelectOptionSet >
203+ > ( "statuscode" ) ;
204+ if ( multiSelectOptionSetAttributeEnum !== null ) {
205+ const multiSelectOptionEnumValue : TestMultiSelectOptionSet [ ] | null = multiSelectOptionSetAttributeEnum . getValue ( ) ;
206+ }
207+
173208/// Demonstrate setFormNotification
174209
175210let level : Xrm . FormNotificationLevel ;
@@ -634,7 +669,7 @@ const multiSelectOptionSetControl = formContext.getControl<Xrm.Controls.MultiSel
634669if ( multiSelectOptionSetControl === null ) {
635670 throw new Error ( "Control does not exist!" ) ;
636671}
637- // $ExpectType MultiSelectOptionSetAttribute
672+ // $ExpectType MultiSelectOptionSetAttribute<number>
638673multiSelectOptionSetControl . getAttribute ( ) ;
639674
640675// Demonstrates getWebResourceUrl
0 commit comments