Topic
This article explains how to use Ninja-Property-Docs-Options-Singleto retrieve valid values for a dropdown or multi-select custom field in a single document.
Environment
- NinjaOne
- Microsoft PowerShell
Description
This cmdlet retrieves valid values for a dropdown or multi-select custom field in a single document. You can specify the field name using the -AttributeName parameter and the document using the -TemplateName parameter. The cmdlet returns a list of valid options in the format <guid>=<name> , where <guid> is the unique identifier for the option and <name> is the display name of the option. Only document fields with automation read permissions can have their options retrieved using this cmdlet.
Syntax
Ninja-Property-Docs-Options-Single [[-TemplateName] <Object>] [[- AttributeName] <Object>] [<CommonParameters>]
Examples
Example 1: A Dropdown Custom Field
PS C:> Ninja-Property-Docs-Options-Single -TemplateName "My Example
Document" -AttributeName "exampleDropdown"
09d9ef8e-3cdf-4fb2-baf6-9b78b46643a9=Example Option 3
1ff0944e-2bc8-4681-909b-688e77db1cae=Example Option 2
61010919-654f-4448-ba15-48a160d42f44=简体中文
bd182518-e0ca-4a50-9afb-f9542c1e7d08=Mötley Crüe
c2444bd4-2e75-4acf-944d-b73afd66b27f=Example Option 1When a dropdown custom field is specified, the cmdlet returns the valid options for the dropdown field in the format <guid>=<name> , where <guid> is the unique identifier for the option and <name> is the display name of the option.
Example 2: A Multi-Select Custom Field
PS C:> Ninja-Property-Docs-Options-Single -TemplateName "My Example
Document" -AttributeName "exampleMultiSelect"
1e6bcc4a-0272-414e-a77c-4109ef79f86e=Option 1
3e08d167-e830-41e7-ae8f-1128e22b00a9=Option 3
4f4f73ba-0d69-4518-a78b-9ca554471b8e=Option 2
680e655d-0b66-4dba-a96e-dcee77ddd1e4=简体中文When a multi-select custom field is specified, the cmdlet returns the valid options for the multi-select field in the format <guid>=<name> , where <guid> is the unique identifier for the option and <name> is the display name of the option.
Example 3: A Custom Field with No Options
PS C:> Ninja-Property-Docs-Options-Single -TemplateName "My Example
Document" -AttributeName "exampleTextField"When a custom field that does not have options such as a text field is specified, the cmdlet returns no output.
Parameters
-AttributeName
Specify the name of the custom field for which you want to retrieve valid options.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False-TemplateName
Specify the name of the single document containing the custom field for which you want to retrieve valid options.
Type: Object
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseInputs
System.String
The cmdlet does not accept input from the pipeline. The -TemplateName and -AttributeName parameters accept string values representing the name of the single document and the name of the custom field, respectively, for which you want to retrieve valid options.
Outputs
System.String[]
The cmdlet returns the valid options for the specified custom field in the specified single document in the format <guid>=<name> as a string or an array of strings if more than one option is available.
- This cmdlet is only applicable for dropdown and multi-select custom fields. If a different
type of custom field is specified, no output will be returned. - Only document fields with automation read permissions can have their options retrieved using this cmdlet. For information about permissions for custom fields refer to NinjaOne Custom Fields: Getting Started.
Additional Resources
For more information about asset management and custom scripting, refer to the following resources: