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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.