Hi, I am looking for the option to get user login id and pass the value to query stirng to url .
help please?
Thanks,
Laskhmi
the below code is working to get user login id with confluence 5.1.3:
<script type="text/javascript">
alert(AJS.Data.get("remote-user"));
</script>
<script type="text/javascript"> var init = 0; function download() { var url = document.getElementById("dload_frame").src; var userEmail; var userlogin = AJS.Data.get("remote-user"); var userName= AJS.Data.get("user-display-name"); var arr=userName.split(","); var Firstname=arr[1]; var Lastname=arr[0]; userEmail = userlogin+"@xyz.com" ; var url1="http://www.abc.com?firstname=" + Firstname + "&lastname=" + Lastname + "&email="+ userEmail; document.getElementById("dload_frame").src = url1; } </script> <iframe id="dload_frame" src="" width="800" height="400" frameborder="0" scrolling="no" > </iframe> <script> download(); </script>
The provided code should be HTML macro. this code is to pass frist name, last name and email id from confluence logged in user and passing values to iframe url.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try with this
<script type="text/javascript"> alert(AJS.Meta.get("ajs-user-display-name")); alert(AJS.Meta.get("ajs-remote-user")); </script> or <script type="text/javascript"> alert(AJS.params.loggedInUser); alert(AJS.params.remoteUser); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
if you are tyring to get through jira api then use this
ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
or if you are trying to get in JAvaScript then try with this
AJS.params.loggedInUser or function getCurrentUserName() { var user; AJS.$.ajax({ url: "/confluence/rest/prototype/1/user/current", type: 'get', dataType: 'json', async: false, success: function(data) { user = data.username; } }); return user; }
and check this post
https://answers.atlassian.com/questions/167046/expose-the-value-of-action-remoteuser-name-to-javascript?page=1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad, Thans for the prompt reply.
can you also let me know the variable to get user's firstname and lastname?
My idea is to get everyting done through HTML code in confluence. Basically this HTML code will get the user login id and pass that value to querystring of the url in iframe tab.
will the above suits for my requirement? please suggest.
Thanks,
Lakshmi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check now i have updated my answer!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prasad, thanks again!
I have just tried above provided code by placing between <script language="Javascript"> </script>. i tried to display the user value using alert(user) instead. but code did not work . getting alert message 'undefined' after save the page.
below is the code i tried to put in HTML macro
<script language="Javascript"> var user; AJS.$.ajax({ url: "/confluence/rest/prototype/1/user/current", type: 'get', dataType: 'json', async: false, success: function(data) { user = data.username; } }); alert(user); </script> |
did i place something wrong? please help me this non-programmer.
or guide me how to use AJS.params.loggedInUser in script?
Thanks,
Lakshmi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.