Case UI Action - Mandatory Field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 08:20 AM
On our Case form/table, we have a UI Action/Form button called Propose Solution. Below is the current script for that UI Action. I want to add a condition, where if the Close category [u_close_category] (choice field) is Migration AND the priority is either 1 -Critical or 2 -High, I want the u_explanation_for_sla field (text) to be mandatory when the Propose Solution button is clicked. I assume the current UI Action needs to be updated. But, if there's another way this can be handled besides updating the current UI Action, I'm open.
Current UI Action Script:
// Add the content of close_notes as an Additional Comment
var proposedSolution = current.close_notes;
if (proposedSolution) {
var commentText = 'The following solution has been proposed for this Case:\n' + proposedSolution;
current.comments = commentText;
// No need to call update here as StateFlow likely handles it
}
// Process the flow and let it handle updating the record
new global.StateFlow().processFlow(current, '8db14a63c3123100d6d210c422d3ae7a', 'manual');
// Stay on the same page after closing the case
action.setRedirectURL(current);
// No need for current.update() here
UI Action Condition:
!current.isNewRecord() && new global.StateFlow().validFlow(current, '8db14a63c3123100d6d210c422d3ae7a', 'manual') && new global.CSUIActionsImpl().isVisible('69d14a63c3123100d6d210c422d3aed1', current.sys_class_name)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2025 09:15 AM
This will need to be set up as a UI Policy. Since you'll set the field as mandatory for your conditions, OOTB logic will prevent the UI Action from executing if the mandatory field is empty. The reason you can't do this in your UI Action is because the UI Action is executing server-side script. Further, best practice would recommend using a UI Policy to achieve this. If you went the UI Action route, you'd need to make a client-side UI Action, build in all of your conditions (probably including one that checks if the field is already empty).