- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 04:51 AM
Hi All
I wanted a widget which is a button to redirect to different catalog items, I dont want to hard code url using dev12345, rather i want it to be fetched from gs.getProperty('instance_name') which am able to get. But I am not able to pass it to the client script to use action.redirect(). How can this be achieved?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 04:57 AM
Hi,
If you have certain variable value in server script, you can just pass it into data object of widget server script.
i.e. data.myVariable = gs.getProperty('instance_name');
Now in client script,
Just use, $scope.data.myVariable to fetch the value set in server script part.
Please let me know if you are looking for something else.
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 04:57 AM
Hi,
If you have certain variable value in server script, you can just pass it into data object of widget server script.
i.e. data.myVariable = gs.getProperty('instance_name');
Now in client script,
Just use, $scope.data.myVariable to fetch the value set in server script part.
Please let me know if you are looking for something else.
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2018 05:40 AM
Thanks Gaurav 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2019 01:05 PM
Hi Gaurav,
seeing your post and looking to do exactly this...however my script isn't working...can you take a look? I'm trying to pass the "data.queueNumber" value from the server to the client so I can use it in a "addInfoMessage". The info message keeps showing "undefinded"...can you see what I'm doing wrong? thanks
SERVER SCRIPT:
var gaIncCount = new GlideAggregate('incident');
gaIncCount.addQuery('active','true');
gaIncCount.addQuery('assignment_group','f57bbd87ebff23008f833c4fea887e46');
gaIncCount.addQuery('contact_type','walk-in');
gaIncCount.addAggregate('COUNT');
gaIncCount.query();
if(gaIncCount.next()){
var queueNumber;
data.queueNumber = gaIncCount.getAggregate('COUNT'); //this is what I want to pass to the client
}
CLIENT SCRIPT
function($scope, spUtil, $window) {
var c = this;
c.data.user = {value:'',displayValue:''};
c.click = function(){
c.data.user.displayValue='';
c.data.user.value='';
c.data.short_description = '';
}
c.addItem = function(){
var user = c.data.user.value;
var desc = c.data.short_description;
if(user == '' || user == 'undefined' || user == 'null' || desc == 'null' || desc == '' || desc == 'undefined'){
alert('Please enter your name and a description of your issue before submitting.');
return;
}
var queueNumber = $scope.data.queueNumber; //this is where I need to put the value from the Server Script
spUtil.addInfoMessage('Thank you, a ticket has been created on your behalf. You are number '+queueNumber+' in the queue. You will now be redirected to the Tech Hub home screen.');
c.server.update().then(function(response){
c.data = {};
$scope.c.affected_user.value = '';
}) }
}