I need to make a field SEO_Type of asset visible when the Label_BM filed is BM_SEO and invisible when the label is any other during the ticket creation.
I use the following script and it makes a field SEO_Type of asset invisible in any case:
const labelsBMField = getFieldById("customfield_12525");
const seoTypeOfAssetField = getFieldById("customfield_12702");
seoTypeOfAssetField.setVisible(true);
const labelsBMValue = labelsBMField.getValue()?.name;
if (labelsBMValue == 'BM_SEO') {
seoTypeOfAssetField.setVisible(true);
} else {
seoTypeOfAssetField.setVisible(false);
}
What is wrong?
i @ganna_kyselevych
You have to store value as string to compare. Let me know if it works
const labelsBMValue = labelsBMField.getValue()?.name.toString(); //Converts value to string
If above doesnt work Try below code
const labelsBMValue = labelsBMField.getValue().toString(); //Converts value to string
Unfortunately, nothing changed 😞
First option:
const labelsBMField = getFieldById("customfield_12525");
const seoTypeOfAssetField = getFieldById("customfield_12702");
seoTypeOfAssetField.setVisible(false);
function updateVisibility() {
const labelsBMValue = labelsBMField.getValue()?.name.toString();
if (labelsBMValue === 'BM_SEO') {
seoTypeOfAssetField.setVisible(true);
} else {
seoTypeOfAssetField.setVisible(false);
}
}
labelsBMField.onChange((fieldId, newValue, oldValue) => {
updateVisibility();
});
updateVisibility();
Second option:
const labelsBMField = getFieldById("customfield_12525");
const seoTypeOfAssetField = getFieldById("customfield_12702");
seoTypeOfAssetField.setVisible(false);
function updateVisibility() {
const labelsBMValue = labelsBMField.getValue().toString();
if (labelsBMValue === 'BM_SEO') {
seoTypeOfAssetField.setVisible(true);
} else {
seoTypeOfAssetField.setVisible(false);
}
}
labelsBMField.onChange((fieldId, newValue, oldValue) => {
updateVisibility();
});
updateVisibility();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.