Hi,
Got a specific CSV list of almost 1,500 community users which I need to reward with a badge. There is no connection or community-related logic behind the list members. How to automate the assigning the badge for them?
Thank you!
Solved! Go to Solution.
@Myko_P -
As there is no direct call to add a badge to users.
There is only one way I can think of, you need to create a role for each badge. e,g you CSV file
id, badge name1
id2,badge name 2
One way you can add a new column with role name
id, badge name1, badge_name1 or you can have the same role name as the badge.
You need some customization to assign a role from CSV file. Below is the API call you can use to assign a role
http://community.lithium.com/community-name/restapi/vc/roles/id/[id] /users/add
From the badge rule, you can choose Roles and map to according to the badge.
When a role is assigned to the users, a new badge will be assigned as well. Let me know if this helps.
Thank you, @TariqHussain ,
I got only community's usernames (user logins) in my CSV list with no user-ids. And I have to assign the same badge to each user from the list. I created a role "Online-Gamer" and the badge named "Online-Gamer" for that.
My CSV list has 2 columns now: user_login,badge_name
So how should my API call look like to assign the same role for the different user names (user logins)?
You can pass login/username in the API as well. e.g
jQuery.post("/restapi/vc/roles/id/<roleID>/users/add?role.user=login/<username>");
As in the CSV file, you have roles name not the roles id. You will need to make another call to get the role id which can be passed in add role call.
/restapi/vc/roles/name/<roleName>
Thank you so much on that @TariqHussain !
It is still not clear to me, what kind of customization I need to assign a role from CSV file?
@Myko_P- Example below is your CSV file.
username, role
Myko_p, gamer TariqGrazitti, gamer
testuser, gamer
testuser2, gamer2
<#assign csv = "Myko_p, gamer tariq, gamer testuser, gamer testuser2, gamer2" /> <#assign csv = csv?split("\n") /> <#list csv as row> <#assign column = row?split(",") /> <#assign userName = column[0] /> <#assign roleName = column[1] /> <#assign roleID = restadmin("/roles/name/${roleName?trim}").role.id /> <#assign roleID = restadmin("/roles/id/${roleID}/users/add?role.user=login/${userName?trim}") /> </#list>
Note: in the above example I have stored CSV content directly on the component as a variable. You can also create something where you can upload CSV file and send the CSV data to an endpoint.
Below is the example how to read csv file http://jsfiddle.net/W8fME/266/
Thanks for the advise @ClaudiusH ,
I tried to import roles from my CSV using the way you mentioned.
But It looks like nothing happens. New Role didn’t appear in the Community Admin > Users > Permissions > Roles interface. I didn’t receive any error messages and email notifications despite the fact I checked “Send confirmation email” option.
Forgive me if I've made an incorrect assumption, but it sounds as though you have missed the step of creating the new role.
The CSV input process is just for assigning users to an existing role. It will ignore roles that do not already exist.
Hope that helps,
Jason
@JasonHill wrote:
Forgive me if I've made an incorrect assumption, but it sounds as though you have missed the step of creating the new role.
The CSV input process is just for assigning users to an existing role. It will ignore roles that do not already exist.
Thank you @JasonHill, you were right.
But it didn't help. I created needed role first and repeated role import procedure with my CSV, but nothing happened again. When I click "List Users" button in Community Admin > Users > Permission > Roles interface I see that role's user list is empty.
I am starting to think that the Import Roles feature is just broken
Hi @Myko_P,
We had a similar requirement in our community to assign a badge to a list of specific users. I have followed the same approach as mentioned by @ClaudiusH and it worked like a charm!
Just listing the steps I followed in detail, if it helps.....
1. Created the new role in Admin -> Users -> Roles -> Create New Role
2. Have the .csv file ready with the list of users who should be assigned the new role and then the badge (username in col A and New Role in col B of the csv).
3. Now select Users -> Badges -> Create. Click the 'Create' button.
4. Create the new badge name, badge image, and set the badge rule 'Roles...' from the drop-down and enter the new role name. Click 'Save'.
5. Now click 'Go Live'.
6. Select Admin -> Users -> Import Roles. Choose the .csv file to import and click 'Save'.
7. To ensure the users have been assigned the new role, click Admin -> Users -> Roles. Click on 'List Users' button against the new role name. The users for that role will be listed at the bottom of the same page.
..... and it's done! The badge is assigned to all users in the .csv.
Important: If you want members to be notified (via email or real-time notifications) of a role-based badge, you must go live with the badge first, and then add the role for that member. If the member already has the role before the badge goes live, the member will not be notified.
Thanks,
Srujana.
Thank you for such a detailed explanation @srujanayeruvaka. Especially for that one:
Important: If you want members to be notified (via email or real-time notifications) of a role-based badge, you must go live with the badge first, and then add the role for that member. If the member already has the role before the badge goes live, the member will not be notified.
The solutions previously mentioned by the @ClaudiusH and @JasonHill finally worked for me.
To my surprise I found that when I convert XLS file on my Mac to the CSV format in Excel the result file I get just doesn't work with the community admin role importing tool.
So I tried to use Apple's Numbers instead of the Excel and the CSV file I get just finally was successfully imported.
So I want to say thank you for all of you, guys, for your great help
It's been a (few) minutes - has there been any updates on the platform that allows you to assign a badge to a specific list of users from a csv or is it still role based?
Welcome to the Technology board!
Curious about our platform? Looking to connect on social technology? You've come to the right place!