- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 07:10 AM
Hi,
I'm trying to make close_notes mandatory(by default this field will be read only) when canceling a change task using a UI button which i have created as below:
Action Name: cancelRecord
Client checkbox: True
onClick: cancelTask();
function cancelTask() {
if (g_form.getValue('close_notes' == '')) {
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', 'Enter Close Notes', 'error');
return false;
} else {
alert('Cancelling the task');
gsftSubmit(null, g_form.getFormElement(), 'cancelRecord');
}
}
if (typeof window == 'undefined') {
cancelTaskRecord();
}
function cancelTaskRecord() {
current.state = '4';
current.update();
action.setRedirectURL(current);
}
But I can't make close notes mandatory. The control always goes into the else block, and I'm able to cancel it, but I'm not getting an error to fill in the close notes.
Please help me.
Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2024 12:18 PM
@Shidhi Ideally creating an additional ACL on the change request/task table should work. User should be able to get access on your new ACLs on the close_notes field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 07:31 AM - edited 08-28-2024 07:31 AM
Hi @Shidhi ,
It's the code on line 2nd line.
if(g_form.getValue('close_notes') == '') instead if(g_form.getValue('close_notes' == ''))
Close the bracket and then check the value.
If this information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 07:43 AM
@Shidhi Please try the following.
function cancelTask() {
var closeNotes = g_form.getValue('close_notes');
if (closeNotes=='') {
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', 'Enter Close Notes', 'error');
return false;
} else {
alert('Cancelling the task');
gsftSubmit(null, g_form.getFormElement(), 'cancelRecord');
}
}
if (typeof window == 'undefined') {
cancelTaskRecord();
}
function cancelTaskRecord() {
current.state = '4';
current.update();
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 07:47 AM - edited 08-28-2024 07:51 AM
The above suggest by Najmuddin didn't work for me, but the following change to the script did work:
var cn = g_form.getValue('close_notes');
if (cn == '') {
I now see Sandeep posted the same change I proposed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 08:06 AM - edited 08-28-2024 08:25 AM
Hi All,
Thanks for your help, now the control is going to If block.
As mentioned earlier, close_notes will be read-only. I'm trying to make it editable to enter comments, but it is not working.
function cancelTask() {
if (g_form.getValue('close_notes') == '') {
g_form.setReadOnly('close_notes', false); //this is not working
g_form.setMandatory('close_notes', true);
g_form.showFieldMsg('close_notes', 'Please provide Close Notes', 'error');
return false;
} else {
alert('Cancelling the task');
gsftSubmit(null, g_form.getFormElement(), 'cancelRecord');
}
}
if (typeof window == 'undefined') {
cancelTaskRecord();
}
function cancelTaskRecord() {
current.state = '4';
current.update();
action.setRedirectURL(current);
}
Is it possible to make it editable when I click on the UI button only? Because I'm not allowed to make changes to the existing setup there is a UI Policy making it Readonly.
Any help is appreciated.
Thank you!