Skip to end of metadata
Go to start of metadata

Availability

This routine is available starting with SIL Engine™ 4.8.0.7.

Syntax

admSetCustomFieldOptionEnabledState(fieldName, fieldOption, projectKeys, issueTypes, useDefaultScheme, enableOption)

Description

Updates the enabled/disabled state of a specific custom field option for the specified context. If the context does not exist, it will be created. If the project keys and issue types are not specified (empty arrays), the global context will be used.
This routine only handles custom fields of the following types: single select, multi select, radio buttons, checkboxes and cascading selects.


Parameters

Parameter name

Type

Required

Description

fieldNamestringYesName of custom field.
fieldOptionstring or string arrayYes

The field option that will be enabled or disabled.

To handle cascading select custom fields children options, use string array, and fill the first array position with the parent field option, and the second one with the child field option.

projectKeysstring arrayYes (can be empty array)Project keys.
issueTypesstring arrayYes (can be empty array)Issue types.
useDefaultSchemebooleanYesSpecify if you want to use the default configuration scheme (or context) of this custom field.
enableOptionbooleanYes

Specify if you want the option to be enabled (set as true) or disabled (set as false).

Return type

boolean (true/false)

Returns 'true' if the options were successfully updated and 'false' otherwise. If returned 'false' check the log for a detailed reason on why it failed.


Examples

Example 1 - Enabling a Single Select Custom Field option

Example 1: The following line of code will enable the custom field option "myoption" from the single select field called "CF_SINGLE_SEL".

admSetCustomFieldOptionEnabledState("CF_SINGLE_SEL", "myoption", {}, {}, false, true);

Example 2 - Disabling a Single Select Custom Field option

Example 2: The following line of code will disable the custom field option "myoption" from the single select field called "CF_SINGLE_SEL".

admSetCustomFieldOptionEnabledState("CF_SINGLE_SEL", "myoption", {}, {}, false, false);

Example 3 - Disabling a Cascade Select Custom Field child option

Example 3: The following line of code will disable the custom field option "child" from the cascade select field called "CF_CASCADE". The "child" options is a sub-option of the "parent" option.

admSetCustomFieldOptionEnabledState("CF_CASCADE", {"parent", "child"}, {}, {}, false, false);

Example 4 - Disabling a Cascade Select Custom Field parent option

Example 4: The following line of code will disable the custom field option "parent" from the cascade select field called "CF_CASCADE". Note that no child options will be disabled. but because the parent is disabled, the children will not show up either on the UI.

admSetCustomFieldOptionEnabledState("CF_CASCADE", "parent", {}, {}, false, false);



The disabled options are still visible on the issues where the custom field value has been set before the DISABLE operation took place. They will not show anymore on the new issues or issues that have ENABLED values set in the custom field.


See also