g_model workspace popup doing same function if i click on cancel or close the popup using cross???

KM SN
Tera Expert

Actually for my requirement i have to show popup having "create new' and 'add from existing' button but as i am unable to find it ...i have used  g_model.confirm() and i have written create new functionality on click on ok and add from existing functionality on click of cancel. 

 

but even if i close popup using cross cancel functionality is working . how to avoid it? or else is there any other possibility except g_model  to show popup in workspace.

 

let me have your ideas here.

 

Thank youconfirm.PNG

 

@Prince Arora  @Ankur Bawiskar  @Rahul Kumar17  @K Akhila @AndersBGS @Anurag Tripathi @AnveshKumar M @Bharath Kumar A @Sandeep Rajput 

8 REPLIES 8

nayanawadhiya1
Kilo Sage

Hello Mani,

 

As per my understanding you want to remove the cross button from the g_modal window.

If yes then you can write below code into your workspace client script section - 

var checkExist = setInterval(function() {
		if (top.document.getElementsByClassName('close pull-right')[0]) {
			clearInterval(checkExist);
			var x = top.document.getElementsByClassName('close pull-right')[0];
			x.style.display = "none";
		}
	}, 100); // check every 100ms

Hi @nayanawadhiya1  Thanks for reply.

 

i am attaching the client script over here .....can you tell me where i need to add your piece of code.

 

Actually for back end i am using Glidemodal and for workspace i am using g_modal, is there anything that can be possible with one thing that reflects both back end and front end so that i can optimize the code right?

 

and in back end i am showing the popup as with create new and add existing buttons where as i am unable to populate same in workspace so i did it with g_model that to with buttons ok and cancel.

 

let me have suggestion so that i can optimize my code in better way.

 

Client Script:

function onSubmit() {
   
    var isnew = g_form.isNewRecord();
 
    if (isnew) {
 
if(!g_form.getValue('constituent_pofile')){
 
        if (g_scratchpad.isFormValid)
            return true;
 
        var first_name = g_form.getValue('x_guid2_child_welf_first_name');
        var last_name = g_form.getValue('x_guid2_child_welf_last_name');
        var dob = g_form.getValue('date_of_birth');
        //var result = '';
 
        var script_include = new GlideAjax('ChildInformationUtils');
        script_include.addParam('sysparm_name', 'getrecord');
        script_include.addParam('sysparm_first_name', first_name);
        script_include.addParam('sysparm_last_name', last_name);
        script_include.addParam('sysparm_dob', dob);
        script_include.getXMLAnswer(setAnswer);
        return false;
 
function setAnswer(answer) {
 
//alert(answer);
            if (answer != null) {
 
                var url = '' + top.location.href;
 
                if ((url.indexOf('agent') > -1)) { 
 
                    var msg = "User is already exists in the system, Please select required action form below";
                    g_modal.confirm(getMessage("Confirm"), msg, function(confirmed)
 
                        {
                            if (confirmed == true) {                       
                           g_form.setValue('constituent_pofile', answer);                            
                                 var actionName1 = g_form.getActionName();
                                    g_scratchpad.isFormValid = true;
                                     g_form.submit(actionName1);
                                return false;
                            } 
 
else if(confirmed == false) {
var actionName2 = g_form.getActionName();
                            g_scratchpad.isFormValid = true;
                            g_form.submit(actionName2);  
return false;
                            }
                        });
 
                } else {
 
// alert('its native ui right?');
// alert(answer);
                    var gm = new GlideModal('x_guid2_child_welf_child_window_dialog_box', true, 600);
                    gm.setTitle('Confirm');
                    gm.setPreference("sysparm_fname", first_name);
                    gm.setPreference("sysparm_lname", last_name);
                    gm.setPreference("sysparm_dob", dob);
                    gm.setPreference('sysparm_search', answer);
                    gm.render();
                }
            } else {
 
                var actionName = g_form.getActionName();
                g_scratchpad.isFormValid = true;
                g_form.submit(actionName);
 
            }
        }
       
    }
}
}
}

Try this - 

function onSubmit() {
   
    var isnew = g_form.isNewRecord();
 
    if (isnew) {
 
if(!g_form.getValue('constituent_pofile')){
 
        if (g_scratchpad.isFormValid)
            return true;
 
        var first_name = g_form.getValue('x_guid2_child_welf_first_name');
        var last_name = g_form.getValue('x_guid2_child_welf_last_name');
        var dob = g_form.getValue('date_of_birth');
        //var result = '';
 
        var script_include = new GlideAjax('ChildInformationUtils');
        script_include.addParam('sysparm_name', 'getrecord');
        script_include.addParam('sysparm_first_name', first_name);
        script_include.addParam('sysparm_last_name', last_name);
        script_include.addParam('sysparm_dob', dob);
        script_include.getXMLAnswer(setAnswer);
        return false;
 
function setAnswer(answer) {
 
//alert(answer);
            if (answer != null) {
 
                var url = '' + top.location.href;
 
                if ((url.indexOf('agent') > -1)) { 
 
                    var msg = "User is already exists in the system, Please select required action form below";
                    g_modal.confirm(getMessage("Confirm"), msg, function(confirmed)
 
                        {
                            if (confirmed == true) {                       
                           g_form.setValue('constituent_pofile', answer);                            
                                 var actionName1 = g_form.getActionName();
                                    g_scratchpad.isFormValid = true;
                                     g_form.submit(actionName1);
                                return false;
                            } 
 
else if(confirmed == false) {
var actionName2 = g_form.getActionName();
                            g_scratchpad.isFormValid = true;
                            g_form.submit(actionName2);  
return false;
                            }
                        });
 
                } else {
 
// alert('its native ui right?');
// alert(answer);
                    var gm = new GlideModal('x_guid2_child_welf_child_window_dialog_box', true, 600);
                    gm.setTitle('Confirm');
                    gm.setPreference("sysparm_fname", first_name);
                    gm.setPreference("sysparm_lname", last_name);
                    gm.setPreference("sysparm_dob", dob);
                    gm.setPreference('sysparm_search', answer);
                    gm.render();
                }
            } else {
 
                var actionName = g_form.getActionName();
                g_scratchpad.isFormValid = true;
                g_form.submit(actionName);
 
            }
        }
		var checkExist = setInterval(function() {
		if (top.document.getElementsByClassName('close pull-right')[0]) {
			clearInterval(checkExist);
			var x = top.document.getElementsByClassName('close pull-right')[0];
			x.style.display = "none";
		}
	}, 100); // check every 100ms
       
    }
}
}
}

KM SN
Tera Expert

No, its not working.

 

still i able to see cross and if i click on cross its doing same like what will happen if i click on close.