How to close modal window when record producer is submitted

victor21
Tera Guru

Hi Listers,

We are currently displaying a record producer in a modal window using ui page

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

	<g:evaluate var="jvar_url" 
		expression="RP.getWindowProperties().get('url_param')">
	</g:evaluate>

	<iframe id="rp_frame" src="${jvar_url}" width="800" height="600" />

</j:jelly>

The problem is that when the producer Submit button is clicked, the new created record is displayed inside the dialog window. Is there a simple way to just close the modal window after the producer is submitted?.

Thanks for your help.

Victor

1 ACCEPTED SOLUTION

victor21
Tera Guru

After some investigation I finally found a solution which is not altogether perfect - but serves my purpose. The idea is to use .load() event of the iframe

var iframe = $j('#rp_frame');
iframe.load(function(){
	var catItem = iframe.contents().find('#cat_item_view');
	var catItemId = catItem.attr('id');
	if(!catItemId){
        GlideDialogWindow.get().destroy();
    }
}

Regards,

 

Victor.

 

View solution in original post

9 REPLIES 9

Geetanjali Khy2
Mega Guru

Hi Victor,

 

You can simply add one more line in your record producer like,

producer.redirect="home.do";
Then it will not take you to newly created record.


Please follow below link, it may helps,
https://community.servicenow.com/community?id=community_question&sys_id=c784177f1b3efb80fff162c4bd4b...


Kindly mark the answer as Correct and Helpful if this answers your question.

Thank You.



Regards,

Geetanjali Khyale

Thanks for your response - but I do not want to redirect somewhere else, I want to close the modal window.

Regards,

Victor

Allen Andreas
Administrator
Administrator

Hi,

In your client script you can use: GlideDialogWindow.get().destroy();

But you'd want to trigger that only when they submit, so on button action.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Yes, Allen - I thought about that - the problem is that the window also closes when the from is not submitted due to some validation error.