Hi,
I have a script which checks some check box and puts in some values in the logwork tab fields.
But now I want that script to execute(check and put values), only for a particular group members
i.e if the user belongs to that particular group ,then only that script should check the checkboxes and put default values i the log work fields.
How can I modify my script?Any ideas ?
Thanks in advance.
Regards,
Asif
jQuery(document).ready(function() {
var project_name = $('#project-name-val').text();
var user_group=$(userUtil).getGroupsForUser();
alert(+user_group);
{
//var user_name = $('#user-name-val').text();
//var assignee_name= $(' #assignee-name-val').text();
//alert(+project_name);
//var user_group=$(userUtil).getGroupsForUser();
if(user_group == ('group1')
{
window.alert('Message goes here');
$('#popup_type1_').attr('checked','checked');
$('#popup_type2_').attr('checked','checked');
$('#popup_type3_').val('0');
}
});
again, i want to check is the user belong to group 1.what changes i should make in he code. am i using the getgroupsforuser method correctly?if not, could you please show me the right way?
thanks in advance
You could check the groups of a user using userUtil.getGroupsForUser().
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
jQuery(document).ready(function() {
var project_name = $('#project-name-val').text();
var user_group=$(userUtil).getGroupsForUser();
alert(+user_group);
{
//var user_name = $('#user-name-val').text();
//var assignee_name= $(' #assignee-name-val').text();
//alert(+project_name);
//var user_group=$(userUtil).getGroupsForUser();
if(user_group == ('group1')
{
window.alert('Message goes here');
$('#popup_type1_').attr('checked','checked');
$('#popup_type2_').attr('checked','checked');
$('#popup_type3_').val('0');
}
});
again, i want to check is the user belong to group 1.what changes i should make in he code. am i using the getgroupsforuser method correctly?if not, could you please show me the right way?
thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, I thought your are talking about a Java or Groovy script...
The method is documented here, you have to provide the user name as an argument. But I don't know if userUtil is available within the velocity context and how to process the returned SortedSet of Groups in velocity.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If userUtil is available it should be possible...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As of https://developer.atlassian.com/display/JIRADEV/Contents+of+the+Velocity+Contextit should be available as "userutil". And the user as remoteUser, so remoteUser.name should be the user name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't know, did you tried it? The page says "Velocity Context used to process web templates", so it's not only email templates.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
jQuery(document).ready(function() {
var project_name = $('#project-name-val').text();
alert(+project_name);
var user_group=$(userUtil).getGroupsForUser();
alert(+user_group);
if(project_name == 'abcd')
{
window.alert('Message goes here');
$('#popup_a1_').attr('checked','checked');
$('#popup_b1_').attr('checked','checked');
$('#popup_c1_').val('0');
}
});
in the above code i have used userutil.getgroupforuser method.but iam not sure i am usng it the right way.if i had used it right, i should have got user_group in the alert.but iam not gettingit. also, i have not included/defined userutil anywhere in code.without the fourth line of the code, the code works fine.but i want to extract the group name of the user and then use it further in my code.
Thanks alot for your help so far.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to provide the user name as argument of getGroupsForUser(). I'm not an velocity expert, but I think you have to write
$userutil.getGroupsForUser($remoteUser.name)
to get the groups.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
script shuld not execute for other group members.
example: if there are two groups: group A and B.
then whenever a member of group A logs work, that script should check the check boxes and put default values in the fields of the log work tab. But if members of group B log work, script should not check the checkboxes and should not put values in the fields.
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.