Pass Data Variable from Server Script to HTML <a href="xxxx"> in Widget
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2020 06:32 AM
Need Some Help:
I'm trying to pull a specific record that is on the User table and place it in a <a href="xxxx"> on the Service Portal.
Below is the code that I have already and where I'm looking to place it. Unfortunately, It's not populating anything.
• When I run the Server Script in the Background Scripts and print the record, it displays correctly.
• This leads me to believe that I don't have the correct code for the Binding Markup.
Server Script:
function() {
data.ucsc = ucscLink;
//Get the UCSC URL
var currentUser = gs.getUserID();
var ucscGR = new GlideRecord('sys_user');
ucscGR.addQuery('sys_id', currentUser);
ucscGR.query();
if (ucscGR.next()){
var ucscLink = ucscGR.company.u_custom_field;
}
}
HTML:
<div>
<div class="dropdown" align="center">
<button class="btn-lg btn-danger" type="button" data-toggle="dropdown"><i class="m-b fa fa-cogs fa-4x" style="color:white"></i><br><STRONG>CONTROL</STRONG>
</button>
<ul class="dropdown-menu" align="center">
<li><a href="#">Link 1</a></li>
<li class="divider"></li>
<li><a href="#">Link 2</a></li>
<li><a href="{{data.ucsc}}">UC Self-Care</a></li>
</ul>
</div>
</div>
Labels:
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2020 09:39 AM
Hi Jonathan,
what if you try the following?
function() {
//Get the UCSC URL
var currentUser = gs.getUserID();
var ucscGR = new GlideRecord('sys_user');
ucscGR.addQuery('sys_id', currentUser);
ucscGR.query();
if (ucscGR.next()){
var ucscLink = ucscGR.company.u_custom_field;
}
data.ucsc = ucscLink;
}
Then replace Link 1 in your HTML with data.ucscLink and wrapped in double curly brackets.
For some reason the syntaxt breaks here in the posts on the community...hence I mention the double curly brackets seperately.
Does it now display the link?
Warm regards,
Stijn
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2020 09:42 AM
Where is data.ucsc in HTML ? We have to add it in curly brackets in HTML