- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 04:38 AM
Hi guys
I am implementing the google maps API on the portal, however to call it, it is necessary to place the code inside a <script> tag in HTML instead of using the common client script. The problem is that I need to pull information from tables in the servicenow to put on the map, so ideally I would be able to access the data object, from the <script> tag. I tried to use UI script with GlideAjax and the client's GlideRecord, but this type of call just doesn't work from the service portal.
Can someone help me?
I thank you for your attention, have a good day !!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2020 05:40 AM
Hi guys
I was able to solve the problem with the following code:
HTML:
<div>
<script>
setTimeout(function(){
console.log("community: " + top.val);
}, 10);
</script>
</div>
Client Controller:
function($scope, spUtil) {
/* widget controller */
var c = this;
top.val = $scope.data.server;
}
Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
data.server = "test";
})();
The explanation is that when we set the value of "top" in the client controller there is no time for the <script> tag to load it. Then we use the setTimeout() javascript function in the <script> tag to give it a little time.
Regards,
Micael Marinho
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 07:54 PM
in your HTML script please try
{{c.data.server}}
instead of
data.server
In your server script it should be
data.server
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 08:57 PM
Hi
c is not defined at eval
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 09:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 09:34 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2020 10:10 PM
Hi Micael,
Can you try with -
console.log("test: " + top.VAL);
I tried with it, seems to work. Check it once from your end and let me know.
Regards
Omkar Mone