
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 05:29 AM
Hello All,
I was stuck on this particular point and hope someone can point me in right direction.
I want to create a reusable widget (say a modified date picker), I would use it as a variable in multiple catalog items. Now, I'd like some options to dynamically change based on some options specified at the variable definition. (I could store them in a different table in future, but for simplicity assume that one additional field stores this information on 'item_option_new' table. My question is how can I identify which variable is being called in widget's server script?
In client controller I can get this information by using $scope.page.field.sys_id. But, I'd like to have this information at the server side so that I could provide the options from server side.
-Mandar
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2018 02:43 AM
I completely understand what you're trying to do... or so I think. I'm in the same boat.
I have a catalog item on the Service Portal to where I added a macro variable that loads a widget:
Now, when this widget loads, I want to grab the sys_id of the calling catalog item because in the Server Script, I want to query the item_option_new table to get the sys_id's of all the variables:
When the widget initially loads, it runs the Server Script and that's where I can't seem to get the sys_id of the calling catalog item... the same issue you're having.
The only way that I've found do what you're trying to do is by doing this:
However, this is not the way I want to go about it. I need to grab that sys_id before any of the HTML Template code gets rendered.
I forked this into my own question in the Developer Community here (my Developer Community post)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2017 02:21 AM
Hi Ujjawal,
Thanks for the revert.
Actually, I want to fetch some options for the widget. Now, using GlideAggregate it will work on client controller. However, as the flow of the Widget (as I understand) is
Server --> Client Controller --> HTML
I'd like to do all the querying at the initial part itself. That's why want to know if I can access the variable's sys_id at server side.
-Mandar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2017 02:24 AM
Can you please share your code all three parts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2017 08:16 AM
Hi Mandar,
Maybe this picture can help you. It details how to pass data between parts of a widget.
The body/HTML is linked to the controller/client - you don't have to use the data object to communicate between them.
So if you want to get info to the server script, you can do a c.server.update() in the client script, to send over the info.
BR /Miriam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 11:23 PM
Hey Miriam,
Thanks for the reply. It is a very good way to visualize different objects.
My question is regarding the server side object for 'page.field'. I don't want to send it back from client to server, was looking for a way to fetch the page.field details at server side itself.
-Mandar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2017 10:21 AM
Hi Mandar,
You can use c.server.update to send the data to server as mentioned below.
function() {
var c = this;
c.data.abc='Any Name';
c.update = function() {
c.server.update().then(function (response) {
c.data = {};
})
}
}
Server side you can use
if(input)
{
gs.log(input.abc);
}
else
{
//Code for intial load
}
Hope this helps.
Regards
Ujjawal