How to get GlideModal box to appear based on condition

matthew_hughes
Kilo Sage

I've built a GlideModal box within a UI Action and I'm wanting it to only appear if certain conditions are met.

 

The code for my GlideModal box is:

function generateConfirmation() {
    var dd = new GlideModal('Confirm');
    dd.setTitle('Confirm');
    dd.renderWithContent('<div>By clicking "Continue" you are committing to completing the full Access Management Assessment (AMA) process and once started the assessment process cannot be cancelled. <br/> If you do not wish to proceed, click "Cancel".<br/><br/>Please ensure by starting this that you are ready to complete and have evidence available to support responses to full Access Management Assessment. For AMA guidance and evidence requirements please consult the <a href = "https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flloydsbanking.sharepoint.com%2Fsit..." target="_blank">Access Management SharePoint</a> site.</div> <div><button onclick="window.Action(this.innerHTML)">Confirm</button><button onclick="window.Action(this.innerHTML)">Cancel</button></div>');
 
// Function to process the button clicks
    window.Action = function(thisButton) {
        // Close the dialog box as an action has been selected
dd.destroy();
        if (thisButton == 'Confirm') {
            // If the user clicked OK, process the demand completion
            gsftSubmit(null, g_form.getFormElement(), 'continue_scoping');
        }
    };
}
if (typeof window == 'undefined')
    generateorContinueAssessment();

 

I've tried to create the following code to only get the GlideModal box to appear in certain conditions:

var getAssessment = new GlideRecord('asmt_assessment_instance');
getAssessment.addEncodedQuery("metric_type=7e3e99001b6ffc9009dd5e26464bcb6a^stateINready,wip^trigger_id=" + current.getValue('sys_id'));
getAssessment.query();
if(!getAssessment)
generateConfirmation();

 

The above code looks for any entries in the asmt_assessment_instance table where the metric type is 7e3e99001b6ffc9009dd5e26464bcb6a and the State is either Ready or Work In Progress and the Trigger ID is the ID of the current Business Application.  It then states if the conditions are not met then generate the GlideModal box. 

 

I was just wondering if somebody could confirm what I'm doing wrong.

0 REPLIES 0