- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 02:28 AM
Hi All,
I need to make field read-only which contain URL after completing task .
I have tried UI policy and onLoad client script
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2024 11:31 PM
Hi @Vijay kumar S ,
To disable the URL field effectively, we need to perform some DOM manipulation within the onLoad client script. Additionally, please ensure that the "Isolate script" checkbox is set to false when you're editing the client script. This allows us to access the current object model and manipulate the DOM elements as needed.
You can find the ID of the anchor tag by inspecting it using the developer tools (press F12 in your browser, then navigate to the Elements tab and look for the <a> tag).
Here’s an updated version of the script that you can use:
function onLoad() {
setTimeout(function () {
var state = g_form.getValue('state');
if (state == '3' || state == '4' || state == '7' || state == '6') {
g_form.setReadOnly('u_url', true);
var urlAnchor = document.getElementById('incident.u_url_link');
if (urlAnchor) {
urlAnchor.style.pointerEvents = 'none'; // Prevents clicks on the link
urlAnchor.style.cursor = 'default'; // Change the cursor to default
urlAnchor.style.textDecoration = 'none'; // Remove underline
urlAnchor.style.color = 'gray'; // Optionally gray out the link
}
}
}, 1500); // Wait 1.5 seconds to ensure the form and elements are fully loaded
}
Key Points
1. Isolate Script Checkbox: Ensure that the "Isolate script" checkbox is set to false to allow access to the current object model and manipulate elements correctly.
Best regards,
Siddhesh Jadhav
I hope this helps! If this resolves your issue, kindly mark my answer as helpful and accepted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 02:39 AM
Have you written onLoad client script with above script? I assume that "url" is field and not a variable on the catalog form. Can you please confirm?
If it is a field on the table, try below:
Create a UI policy on sc_task table with conditions as State is closed complete or state is closed incomplete or state is closed skipped
and under UI policy action , select URL field -- visible as true
if it is a variable on catalog form, try below:
Create onload client script with the script, you already have. Just double check the field name as custom fields will have name starting with "u_"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 02:52 AM
Thank you for your replay,
yes its a field not variable and field value is correct and I have used alert and got URL.
UI policy also tried but no help on URL other field its making read only not URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 03:14 AM
oh...got it, I think its not possible to make the text not-clickable with straight forward methods. We might need to use DOM manipulation but it is not a best practice. Let me know if you still want to go with DOM manipulation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 08:37 PM