script issue
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 01:18 PM
I create the script below but is not working correctly. i need it that when a task is closed to require the variable to be field out. this is a number input. when a number is entered the field still act like is blank and unable to closed the task.
function onSubmit() {
var newValue = g_form.getValue('state');
if(newValue == 3 || newValue == 4 || newValue == 7) {
if((g_form.getValue('variables.number_of_changes_requested1') ==""));{
g_form.addErrorMessage('Enter Number of Changes Requested.');
return false;
}
}
}
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 01:57 PM - edited 09-20-2023 01:58 PM
I think i know the problem, but still ill add some debugging steps
you dont need a ; here
Debugging steps:
On a Closed RITM
Hit ctrl+shift+alt+J , it will open javascript debugger
Then paste the below and see what alerts you get
var stateVal= g_form.getValue('state');
alert(stateVal);
alert((g_form.getValue('variables.number_of_changes_requested1'));
if(stateVal== 3 || stateVal== 4 || stateVal== 7) {
alert('1');
if((g_form.getValue('variables.number_of_changes_requested1') =="")){
alert('2');
g_form.addErrorMessage('Enter Number of Changes Requested.');
return false;
}
}
-Anurag

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 02:02 PM
Hi @Cherly ,
You can make this field mandatory, which by OOTB not allow user to submit the request and throw and error.
var newValue = g_form.getValue('state');
if(newValue == 3 || newValue == 4 || newValue == 7) {
g_form.setMandatory('variables.number_of_changes_requested1', true);
}
Also seems there is error in your code in if block you are closing the block.
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks
Vijay Balotia
Thanks
Vijay Balotia