UI Action Script Issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 10:35 AM
Hi All,
Need help in scripting.
Condition : UI Action to check if Closure Notes is Empty Of Not. If Empty Prompt for entering the values and then set the value of alert state to 100 and update the record and remain on Same page.
If not empty, set the value of alert state to 100 and update the record and remain on Same page.
--------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 12:35 PM
Solution:
You need to correct the script to handle the update properly after the user enters the value in the "Closure Notes" field. Instead of directly using current in the client-side script, which doesn't work properly in UI Actions, you should use g_form.setValue and g_form.save.
Here’s an updated version of your script:
function checkAndSave() {
var closureNotes = g_form.getValue('u_closure_notes');
if (closureNotes.trim() === '') {
alert('Please enter a value for "Closure Notes" and save the form.');
} else {
g_form.setValue('u_alert_state', 100);
g_form.save();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 07:26 PM
Hi @HIROSHI SATOH it is still not working and keep prompting the alert even after entering the value of closure notes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2024 08:24 PM
Is "g_form.getValue('u_closure_notes');" correctly retrieving the value?