In UI page submit button is not working for non admin users

sharadhir
Tera Contributor

Created UI page containing few checking and submit button. The button functionality is working for admins. But it is not working for any other users when clicked on submit button.

 

5 REPLIES 5

HTML code

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:sn="someNameSpace" xmlns:ui="jelly:newui">
    <div>
        <h2>RCA Review Checklist</h2>
        <p>Please confirm the following items before sending the RCA review request:</p>
        <ul style="list-style:none; padding-left:0;">
            <li>
                <label>
                    <input type="checkbox" id="ci_check" />
                    Have you selected the correct Configuration Item (CI)?(If the incorrect CI is selected, the approval will not be sent to the correct approvers.)
                </label>
            </li>
            <li>
                <label>
                    <input type="checkbox" id="analysis_check" />
                    Have you fulfilled [Analysis Information] tab? (ex. Root Cause, 5 whys analysis, etc.)
                </label>
            </li>
            <li>
                <label>
                    <input type="checkbox" id="kea_check" />
                    Have you created "Known Error Article" and linked with this PRB ticket?
                </label>
            </li>
        </ul>
        <br />
    </div>
    <button type="button" class="btn btn-primary" onclick="submitChecklist()">Submit</button>
    <button type="button" class="btn btn-default" onclick="GlideDialogWindow.get().destroy()">Cancel</button>
</j:jelly>
 
Client script
 
function submitChecklist() {
    // Ensure all checklist items are ticked
    if (!document.getElementById('ci_check').checked ||
        !document.getElementById('analysis_check').checked ||
        !document.getElementById('kea_check').checked) {
        alert('Please complete all checklist items before proceeding.');
        return;
    }
    // Call server-side validation via GlideAjax
    //alert('problem id is'+ g_form.getUniqueValue());
    var ga = new GlideAjax('global.RCAReviewAjax'); // Script Include name
    ga.addParam('sysparm_name', 'sendApproval');
    ga.addParam('sysparm_problem_id', g_form.getUniqueValue()); // current Problem sys_id
    ga.getXMLAnswer(function(response) {
        if (!response) {
            alert("No response received. Please check permissions.");
            return;
        }
        if (response.startsWith('Error')) {
            alert(response); // show error returned from server
        } else {
            alert(response); // success message
            GlideDialogWindow.get().destroy(); // close modal
            window.location.reload(); // refresh form to show updated state
        }
       
    });
}
 
Script include
 
sendApproval: function() {
        var problemId = this.getParameter('sysparm_problem_id');
        if (!problemId) {
            return 'Error: Problem ID not provided.';
        }

        var gr = new GlideRecord('problem');
        if (!gr.get(problemId)) {
            return 'Error: Problem record not found.';
        }

        // --- Validations ---
        if (!gr.cmdb_ci) {
            return 'Error: Please select CI';
        }
        if (!gr.cause_notes || !gr.u_5_whys_analysis || !gr.primary_known_error_article || !gr.u_cause_code) {

            return 'Error: Please complete the Analysis Information tab (Root Cause, 5 Whys, etc.).';
        }
       
        // --- Trigger Event / Workflow ---
        //  gs.eventQueue('problem.rca.review.request', gr, gr.assigned_to, gs.getUserID());
        gr.setValue('u_rca_review_submitted', true);
        gr.update();
        // gs.addInfoMessage('RCA Review Request sent successfully.');
        return 'RCA Review Request sent successfully.';

    }