cLient script not working here i wrote script to make readonly when ticket moved to closed state.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @RAJPRAVEENR
Yes, this can be achieved with an onLoad Client Script. In your script, there are two issues:
getValue() should be used (case-sensitive).
g_form.getEditableFields() is not a supported API in client scripts.
Try this script
function onLoad() {
var st = g_form.getValue('state');
if (st == 7) { // 7 = Closed (for Incident table)
var elements = g_form.getFormElement().elements;
for (var i = 0; i < elements.length; i++) {
var fieldName = elements[i].getAttribute('name');
if (fieldName) {
g_form.setReadOnly(fieldName, true);
}
}
}
}
If you only want to make specific fields read-only instead of all, you can simplify it like this:
function onLoad() {
if (g_form.getValue('state') == 7) {
g_form.setReadOnly('short_description', true);
g_form.setReadOnly('description', true);
g_form.setReadOnly('comments', true);
}
}
This way, once the ticket moves to Closed state, the form fields become read-only for the end user.
If my answer helped you, please mark it - Solution accepted.
Thanks,
Pranita D