I will not say it is difficult, but involves a little more number of steps, because we have to use some extra steps to get current user details as well.
So, Lets Start !
- Create 2 Document Properties time and UserName . We will use time to trigger a IronPython Script to get current user details.
- Add script to Document Property time .
You can use any script to get user information. I used approach from my post on LinkedIn-from Spotfire.Dxp.Framework.ApplicationModel import UserContextr=Application.GetService[UserContext]()Document.Properties["UserName"] = r.Username - Now, create a Data Function with Simple script.
output=input - Define Output Parameter to Document Property time to trigger IronPython code from step 2.
- Define Input Parameter to expression below-
String(DateTimeNow()) - In HTML Text Area, create a Div with Property User enclosed -
<span id='userDet' style="visibility:hidden;">
<SpotfireControl id="52ea70f998bb46c985e49a1d0ca03ada" />
</span> - Add JavaScript for final touch-
if(!$('#AlienBox').length){
$('body').append($(`<style id="AlienBox">
#Brand {
position: absolute;
top: 0px;
right: 40%;
height: 30px;
width: 100px;
z-index: 99;
border: 1px solid chocolate;
border-radius :5px;
color:chocolate;
}
</style>`, {
id: 'AlienBox'
}));
}
innerHTML=`<div id="Brand">
<center> Current User is <br><b>`;
innerHTML+=$("#userDet").text();
innerHTML+=`</b> </center>
</div>`;
if(!$('#Brand').length){
$('body').append($(innerHTML, {
id: 'Brand'
}));
} - Save the Analysis and Close.
- Open Analysis again to see the desired output.