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 send data from Ui page to Ui action using callback

Marli
Tera Contributor

Hi everyone!
I'm open popup from Ui action in CSM workspace this way:

 

Workspace client script:

g_modal.showFrame({
        url: url,
        title: 'Choose resolve method',
        size: 'sm',
        callback: function(response) {
            if(response){
                 alert(response.data); 
            }else{
                 alert('error');
            }
        }
    });


I want to receive data back from UI page i called using functionality:

function validateSelect() {
        var select = document.getElementById('method');
        var message = document.getElementById('validationMessage');
        if (select.value === "") {
            message.style.display = 'block';
            message.innerHTML = "Please select an option.";
        } else {
            message.style.display = 'none';
            message.innerHTML = "";
            sendResponse({action: 'ok', data: select.value});
        }
    }

    function sendResponse(response) {
        window.parent.postMessage(response, "*");
    }
    </script>


I don't get anything. I want to fetch data from a UI page but am getting an error warning. Maybe someone knows what's wrong?

Thanks in advance!

1 REPLY 1

deepakverma12
ServiceNow Employee
ServiceNow Employee

Hi,

Were you able to find the solution?