Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to close the form widget when it open in a popup modal window

vidhya_mouli
Tera Sage

I have a widget with a button. When this button is clicked, the form widget (widget-formopens in a modal popup.

 

Client Script:

api.controller = function($window, spModal) {
    /* widget controller */
    var c = this;
	c.hideWidget = c.data.hideWidget; // Accessing the server data

    // Function to handle button click
   /* c.addSkill = function() {
        var hosturl = 'https://' + $window.location.host;
        $window.open(hosturl + "/esc?id=hoif_form_page&table=cmn_skill&sys_id=-1", '_blank');
    };*/
	

	
	c.onWidget = function(widgetId, widgetInput) {
		spModal.open({
			title: 'Add Skill',
			widget: '36443729eb195a10205cf996bad0cd51', 
			widgetInput: {
				table: "cmn_skill",
				sys_id: "-1",
				view: "ess"
			},
			buttons: [],
			size:'lg'
		}).then(function(){
			console.log('widget dismissed');
		})      
	}
	

    // Check if the widget should be hidden
    c.isVisible = function() {
        // If the hideWidget variable from server is true, return false
        return !c.hideWidget; // Hide the widget if hideWidget is true
    };
};

 

When a user submits/saves the form, it should automatically close this popup window. Not sure how to do this? 

0 REPLIES 0