Amending 'Close' UI Action on Interactions

StewartFletcher
Tera Expert

Good morning,

 

We have a requirement to amend the UI Action 'Close' on Interactions. Currently this just straight up closes an Interaction as Closed Complete, and doesn't require any information being input to advise why.

 

What we want to be able to do is when a user clicks 'Close', it flags the Work Nots field as mandatory and doesn't allow it to be closed.


For ref, this is the current script on the UI Action -:

 

function onClick(g_form) {
    getMessage("Are you sure you want to close this interaction?", function (msg) {
        g_modal.confirm(getMessage("Confirmation"), msg, function (confirmed) {
            if (confirmed) {
                g_form.setValue('state', 'closed_complete');
                g_form.save();
            }
        });
    });

    return false;
}
 
So it gives a confirmation message to the user to confirm they want to close it, then does that. I can set a field to be mandatory when that happens, but it needs to stop the ticket being able to be closed without this information.
 
Still getting to grips with scripting so any advice or hep would be appreciated.
8 REPLIES 8

Could you click the Advanced Related link in the UI Policy, and share a screenshot again?
Also could you provide a screenshot of you closure code dictionary record?


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

StewartFletcher_0-1696414096548.png

 

StewartFletcher_1-1696414171656.png

 

Thanks @StewartFletcher,


It looks ok to me, assuming the default value is empty?

You could use this script in UI action to fill the close notes based on a popup:

function confirmDialog() {
var gm = new GlideModal('confirm');

// Sets the dialog title
gm.setTitle('Confirmation');

// Sets up valid custom HTML to be displayed
gm.renderWithContent('<div style="padding:15px"> <p>Close task?</p> <label for="notes" class="form-label">Provide Close Notes</label> <br /> <textarea name="notes" id="notes"></textarea> <br /> <div style="padding:5px;float:right"> <button style="padding:5px;margin-right:10px" onclick="top.window.takeAction(this.innerHTML)" class="btn btn-default">Cancel</button> <button style="padding:5px" onclick="top.window.takeAction(this.innerHTML,jQuery(\'#notes\').val())" class="btn btn-primary">Submit</button> </div> </div>');

// We'll use the windows object to ensure our code is accessible from the modal dialog
top.window.takeAction = function(thisButton, notes) {
// Close the glide modal dialog window when either button is pressed.
gm.destroy();

// Perform the appropriate action on the client.
if (thisButton === 'Submit') {
g_form.setValue('u_closecode', '<<your closed value>>')
g_form.setValue('close_notes', notes);
g_form.save();
} else if (thisButton === 'Cancel') {
return false;
}
};

return false; // Prevents the form from submitting when the dialog first loads
}

Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Unfortunately putting that in just breaks the button completely. You click it and it does nothing.