diff --git a/Client-Side Components/Catalog Client Script/Dynamic Label Update/README.md b/Client-Side Components/Catalog Client Script/Dynamic Label Update/README.md new file mode 100644 index 0000000000..c89c98ac56 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Dynamic Label Update/README.md @@ -0,0 +1,12 @@ +**Dynamic Catalog Variable Label Update** + +**Description** +This catalog client script dynamically updates the label of one variable based on the value of another. +It's useful when you want to provide contextual labels for dependent fields in Service Catalog items. + +**Example** +If Asset Type = "Software", then the label for "Asset Name" becomes "Software Asset Name". + +**Catalog Client Script Configuration** +- Type: onChange +- Variable name: asset_type diff --git a/Client-Side Components/Catalog Client Script/Dynamic Label Update/dynamic_label_update.js b/Client-Side Components/Catalog Client Script/Dynamic Label Update/dynamic_label_update.js new file mode 100644 index 0000000000..aacbe87e56 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Dynamic Label Update/dynamic_label_update.js @@ -0,0 +1,8 @@ +function onChange(control, oldValue, newValue, isLoading) { + if (isLoading || newValue == '') { + return; + } + + var asset = newValue + ' Asset Name'; + g_form.setLabelOf('asset_name', asset); +}