service catalog ==> catalog item ==> Variable read only after submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 05:48 AM
Hello everyone, (Scope Service catalog ==>catalog item ==> variable read only after submit request)
I want wide single text variable to no longer be read only after submitting the request and that we can write in this field (in the ritm).
Submit Request ==> RITM form ==> Variable wide single text writeable (don't read only)
NB : This is my script
unction onLoad() {
if (!g_user.hasRole('itil')) {
// Get all elements with a specific className
var refs = document.getElementsByClassName("cat_item_option");
if (refs) {
for (var i = 0; i < refs.length; i++) {
var ref = refs[i];
var inner = ref.id;
// Find the label corresponding to the variable
var label = document.querySelector(`label[for='${inner}']`);
// If label is found, you can extract its text
//if (label) {
// g_form.addInfoMessage("Label for " + inner + ": " + label.innerText); // For debugging
//}
// Skip the variable if its label is "Échantillon de clients pour les factures test"
if (label && label.innerText.trim() !== "Échantillon de clients pour les factures test") {
// Make the variable readonly and disabled if the label is not the specified one
ref.readOnly = true;
ref.disabled = true;
}
}
}
}
}
Thank you for your help
Best regards
Socrate

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 08:12 AM
How do you have your system configured to make variables read only? Out of the box variables are not read only by default.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 08:38 AM
what's your actual business requirement?
Why are you using DOM manipulation to make readonly?
share some screenshots
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader