a widget that presents an iframe with "src" to payment getway

Dana Israeli
Giga Guru

i have a widget that presents an iframe with "src" to payment getway everything works fine. 

when i click on proccess [on the external iframe i have, i am getting the DATA response on URL i tell them to which one to send the response.

for the response i created a new Widget that needs to get all the details. 

my problem is that i dont know i to get the response on that widget.

any one can help me please?

 

CODE of FIRST widget:

HTML :

<div class="panel b" ng-init="registrationInit()">
<!-- header -->
<div class="panel-heading bg-primary">
<h3 class="panel-title">${Payment Managment}</h3>
</div>
<body>
<div class="content">
<iframe id="iframe" ng-model="c.data.iframe" width="400" height="600" src="" frameborder="0" allowfullscreen></iframe>
</div>
<div class="content">
<label for="customer_id">${Customer ID: }</label>
<input id="customer_id" name="customer_id" ng-model="c.data.customer_id" ng-required="true">
</div>
<div class="content">
<label for="url">${Iframe URL: }</label>
<input id="url" name="url" ng-model="c.data.url" ng-required="true">
</div>
</body>

server script:

(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
//Static incident sys_id for demo:
var sys_id = gs.getUser().getCompanyID();
data.customer_id = sys_id;
data.url = "https://direct.tranzila.com/bynet/iframenew.php?sum=1&currency=1&cred_type=1&customer="+sys_id;

})();

 

client controller:

function() {
/* widget controller */
var c = this;
var customerSys = c.data.url
document.getElementById("iframe").src = customerSys;
//document.iframename.document.body.innerHTML = serverResponse;
//console.log("document.iframename.document.body.innerHTML :document.iframename.document.body.innerHTML ");
//console.log("serverResponse : " + serverResponse );

}

 

 

 

3 REPLIES 3

Gaurav Sharma11
Kilo Expert

Hi Dana,

If you want to get data from URL in that widget then you can use below line of code:

var customer = $sp.getParameter('customer');

If you want to communicate any value from one widget to another on click on any function/event. You can you widget broadcasting:

https://serviceportal.io/using-events-communicate-widgets/

Please mark the answer as correct, helpful if this answered your question.

Thanks,

Gaurav

my first widget have an i-frame

i need that my second widget will get response from the 1st widget 

you can use events to send data from one widget to other or you can embed your second widget within first one and pass the data as input.

 

1. through embedding widget

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/concept/c_NestedWidgets.html  

2. through events

Widget 1 Client Script

function ($rootScope) {
   $rootScope.$broadcast('response.received', {"name":"testing"});
}

Widget 2 Client Script

function ($scope) {
   $scope.$on('response.received', function(event, data)
{ alert(data.name);
});

}