callback function from UI page always returning false

Saranya Babu1
Tera Expert

@Ankur Bawiskar 

Hello All,

I have created a UI page which should open in workspace and on click of cancel button, I need clear all the field and close the current window.

I am using a on change client script for this

 

Here am getting false always when clicking on cancel and continue button?

 

How can I get get on click on cancel get false and continue button get true value so that I can do my validation?

 

 

      g_modal.showFrame({
        url: "sn_customerservice_s.do?sysparm_stacks=no&sysparm_workspace=" + true + "&sysparm_sys_id=" + g_form.getValue("u_installed_base_item"),
        size: 'lg',
		height: '56vh',
        title: '',
        callback: function(confirmed, data) {
			alert(confirmed);
			
							g_form.setValue("account","");
						
        }
    });
    /* v
<button  onclick="onCancel();" value="false" style="padding: 10px 20px; background-color: #5514B4; color: white; border: none; cursor: pointer;"  name="cancel" id="cancel">${gs.getMessage('Cancel')}</button>
    <button name="submit" value="true" onclick="submitChanges();" id="submit" style="padding: 10px 20px; background-color: #5514B4; color: white; border: none; cursor: pointer;">${gs.getMessage('Continue Creation')}</button>

 

9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@Saranya Babu1 

Did you check any OOB UI actions which invokes modal and uses callback

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes and also go through below two article as well as everywhere its UI action.

I am not getting any result even though used same way.

 

https://www.servicenow.com/community/spm-articles/migrating-existing-ui-actions-in-project-workspace...

https://snpro.dev/2023/11/20/workspace-modals-working-with-ui-pages/

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Saranya Babu1 

check this link and you will get some clarity on how callback functions work with UI pages in workspace

How to use UI Actions in Workspaces 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am not using UI action and its onchange client script.