- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 10:32 AM
Hi All,
I need to pass data from field of one widget to another
How can i achieve this..
Kindly suggest
Thanks in advance..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 01:39 AM
Hello Shipra,
User c.server.get() method in place of GlideAjax, as given in below example where you can pass query / variables in the object from client to server :
//user_details object contains all form field values + query_add variable
//Body HTML Template
<form ng-submit="submitForm(user_details)">
<input type="text" ng-model="user_details.first_name" type="text" placeholder="First Name" class="form-control input-md" required="">
<button type="submit" ng-disabled="user_details.host_invalid == true" class="btn btn-md btn-primary pull-right">Submit</button>
</form>
// Client Controller
function ($scope) {
/* widget controller */
var c = this;
$scope.submitForm = function (user_details) {
user_details.query_add = "active=true";
c.server.get({action : 'validate', user_details : user_details}).then(function(r) {
alert("Response from server "+r.data.result)
});
};
}
// Server script
(function() {
if(input) {
if(input.action == 'validate' && input.user_details.query_add == "active=true"){
// Script for validatation
data.result = true;
}
else {
data.result = false;
}
}
})();
Visit Widget scripting documentation provided by ServiceNow for more infor.
Regards,
Chirag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 02:18 PM
Hi Shipra,
This might be the answer you're looking for:
How to communicate between widgets in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-06-2016 01:39 AM
Hello Shipra,
User c.server.get() method in place of GlideAjax, as given in below example where you can pass query / variables in the object from client to server :
//user_details object contains all form field values + query_add variable
//Body HTML Template
<form ng-submit="submitForm(user_details)">
<input type="text" ng-model="user_details.first_name" type="text" placeholder="First Name" class="form-control input-md" required="">
<button type="submit" ng-disabled="user_details.host_invalid == true" class="btn btn-md btn-primary pull-right">Submit</button>
</form>
// Client Controller
function ($scope) {
/* widget controller */
var c = this;
$scope.submitForm = function (user_details) {
user_details.query_add = "active=true";
c.server.get({action : 'validate', user_details : user_details}).then(function(r) {
alert("Response from server "+r.data.result)
});
};
}
// Server script
(function() {
if(input) {
if(input.action == 'validate' && input.user_details.query_add == "active=true"){
// Script for validatation
data.result = true;
}
else {
data.result = false;
}
}
})();
Visit Widget scripting documentation provided by ServiceNow for more infor.
Regards,
Chirag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2016 06:34 PM
For future reference of those who may not know:
The title of this post is misleading as the correct answer marked here reflects not passing data from widget to widget but passing input data from client to server within the same widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2016 03:52 AM
Thanks Chris for your reply. By mistake, I have answered to this thread instead of send data from client to server in service portal.
