Make Field readonly according to the condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 07:50 AM
Hi Community, Good Day!!!!
As we know that in incident table when we add value on Caller field then for some users, 'location' field's value auto-populates. So, in my requirement, if location field gets auto-populates, make it read-only, like in below:
and when 'location' does not gets auto-populates and user sets it manually, then make it editable even it is set.
Thanks in Advance!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 08:14 PM
Hi @rah dev ,
Based on your description, you can achieve the desired behavior by creating a client script in the catalog item. This client script will run when there's a change in the 'Caller' field. Attached is the snapshot for same. Here's an example of the code you can use:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var loc = g_form.getValue('location'); //get the value of location field
if (loc != '') { // if it has value, then only make it readonly
g_form.setReadOnly('location', true);
}
}
If my answer solves your issue, please mark it as Helpful 👍 and accepted ✔️ based on the impact.