How to check if additional comments is filled in with values or not?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2023 09:29 AM
- In Incident Table create a UI action button with the name “Need More Info”.
This UI Action button will appear only when the State is “In Progress”.
This button should appear only for the person name shown in the field “Assigned to”.
When the “Assigned to” person is using the system and clicks the UI Action button “Need More Info”, the system should check if the Additional Comments are filled in or not. If the Additional Comments are not filled in, then show an error and don’t allow the form to submit.
Once the “Additional Comments” are filled in and the user clicks “Need more Info” the following things should happen.
- The “State” of the incident should be changed to “On Hold”
function runClientCode() {
// Retrieve the value of the 'comments' field
var additionalComments = g_form.getValue('comments');
// Check if the 'comments' field is empty
if (additionalComments == '') {
alert('Please fill in the Additional Comments field before submitting.');
return 'false'; // Prevent form submission
} else {
// Set the values of the 'state' and 'hold_reason' fields
g_form.setValue('state', '3');
g_form.setValue('hold_reason', '1');
}
// Submit the form
gsftSubmit(null, g_form.getFormElement(), 'ui_action_learning');
}
// Check if running in server-side context
if (typeof window == 'undefined')
serverCd();
function serverCd() {
// Update the current record
current.update();
// Set the redirect URL for the server-side UI action
action.setRedirectURL(current);
}
On the else conditions, after I add something in additional comments and then I post it , the error message pops up saying that "Please fill in the Additional Comments field before submitting." So the else condition seems to be not working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2023 10:10 AM
Hi Prithvi,
I tested you UI action function's "if" logic as below:
function runClientCode() {
// Retrieve the value of the 'comments' field
var additionalComments = g_form.getValue('comments');
// Check if the 'comments' field is empty
if (additionalComments == '') {
alert('Please fill in the Additional Comments field before submitting.');
return 'false'; // Prevent form submission
} else {
alert('Additional Comments are present.');
// Set the values of the 'state' and 'hold_reason' fields
g_form.setValue('state', '3');
g_form.setValue('hold_reason', '1');
}
// Submit the form
// gsftSubmit(null, g_form.getFormElement(), 'ui_action_learning');
}
// Check if running in server-side context
if (typeof window == 'undefined')
serverCd();
function serverCd() {
// Update the current record
current.update();
// Set the redirect URL for the server-side UI action
action.setRedirectURL(current);
}
And got the popup as in the screen shot when I clicked the "Need More Info" button. I has to comment out the 'gsftSubmit()' function call (I can't see where that is documented).
I'm not sure what your problem is. but then you don't show the complete UI Action definition.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2023 10:37 AM
See @Bert_c1 you did it absolutely correctly, but the thing is, when you add additional comments you do not post it right. If you post it and then check if it works, then definitely it will not work and that's what I'm trying to make that work.So, if a user posts an additional comment, then if he clicks on the button, then the state should move to on hold, which is not happening and thats what im trying to fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2023 11:13 AM
Hi @Community Alums
I have "Client" clicked on my UI action definition, and the two fields do show being updated. After I acknowledge the alert I have in the 'else' code block. I don't have a 'ui_action_learning' action to use where you have 'gsftSubmit(null, g_form.getFormElement(), 'ui_action_learning');'. So I had to comment that out. I did find KB1005843 that describes "gsftSubmit()".
anyway, seems others here have suggestions for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2023 10:18 AM
Hi @Community Alums
I have done the same as your requirement. Please check the screenshot below.
Note: Make sure the client checkbox is true
Screenshot of the testing record in Incident
Please hit the thumbs up button and mark it as solution provided. Thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2023 12:00 PM
@Community Alums
If found helpful please hit the thumbs up button and mark it as solution provided. Thanks a lot!