state closed= read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:05 AM
Hi
I need that when the state=closed then all the fields in the Incident form will become read only
I am attaching the code:
This is the result, but I need the two fields that are not yet read-only to also be read-only
(service, service offering)
Thank.shir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:12 AM - edited 11-20-2023 05:13 AM
Hi @Shir Sharvit ,
That is because they are mandatory hence they are not becoming read only.
can u try making them as Mandatory false
just add this line after 4th line in your existing code
g_form.setMandatory(field[x],false)
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:26 AM
It doesn't work for me, can you write down the code and where to add it?
function onLoad() {
if (g_form.getValue('state') == 7) { //state is closed
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:27 AM
Hi @Shir Sharvit ,
function onLoad() {
if (g_form.getValue('state') == 7) { //state is closed
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setMandatory(fields[x],false);
g_form.setReadOnly(fields[x], true);
}
}
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 05:36 AM
Hi @Shir Sharvit ,
If our responses helped u please mark it as Solution Accepted as it will help others to find the correct answer.
Thanks,
Danish