Forum Discussion
Hi neel_psl You have to raise a ticket to Lithium support team so they can configure it on your instance.
- neel_psl8 years agoAceOk Thanks
- 7 years ago
Really?? I'm speechless... so to actually get a list of all existing ranks we have to contact support even though there is an official API call for it in v1 and v2 and neither of them works properly...
The v1 call to ranks/list asks for a specific user login or id (via URL parameter) which completely defeats it's purpose, I don't want a USER's rank, I want ALL ranks in the community (this time for translation purposes).
<response status="error"> <error code="306"> <message> A required feature is not configured: user-node-rank. </message> </error> </response>
The v2 call documented here https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=ranks#fields-id just returns an error on a 17.12 (17.12-release r1803051017) community...
{ "status" : "error", "message" : "undefined collection: ranks", "data" : { "type" : "error_data", "code" : 602, "developer_message" : "", "more_info" : "" }, "metadata" : { } }
SuzieH do you know why this is documented but then throws an error like that? It says nowhere that this has to be custom enabled by support?? I'm simply trying
SELECT * FROM ranks
If that's really something that needs to be first enabled by support, please add it to the docs so any confusion and waste of time is avoided in the future.
- SuzieH7 years agoKhoros Alumni (Retired)
Hi GlowingBlue_sc,
We don't provide a v2 API to get a list of all ranks in the Community. I apologize for the confusion in the Ranks collection documentation, The sentence about the Fields table that says "Fields in this table are supported in the SELECT statement of a LiQL query." Is auto-generated, and is a mistake. With v2, you only retrieve ranks for a specific user or a set of users.
In addition, I spoke with of our Community engineers. The ranks/list endpoint is actually used to retrieve a list of Category Expert Ranks (which is called UserNodeRanks in our code), not User Ranks. I'll be clarifying that in the documentation as well. We have a TKB describing the differences between these features here.
- lilim7 years agoBoss
I came across this topic when researching possibilities to export user ranks. I did end up opening a support ticket to ask if it is possible, but unfortunately it is not.
Please consider voting on my product idea here: Allow user ranks to be exported to CSV
- luk7 years agoBoss
Thanks for the idea lilim, upvoted!
Meanwhile I wrote a dirty export script, just execute it within the inspector console on the ranks page in Admin, it will inject a download link called "Export Ranks" which when clicked will give you a text file to download (just rename the .properties file to .csv or .txt or whatever you need, doesn't really matter, its just text):
jQuery('<div id="ranks" />').hide().appendTo('body'); // create fake container for .load() // The ranks are embedded with an iFrame in Admin, and // therefore not accessible directly via JS, that means we first have to fetch // the content of the iFrame, inject it into the DOM and then work from there... jQuery('#ranks').load(jQuery('.lia-component-admin-widget-user-rankings').prop('src') + ' .admin_cell:last', function() { var ranks = []; // initialize variable jQuery('#ranks a[href*="edit&ranking.id"]').each(function() { var $item = jQuery(this); var title = $item.parents('td:first').next().text().trim(); var id = $item.prop('href').split('=').pop(); var output = `rank.${id}.title = ${title}`; ranks.push(output); //console.log(output); }); //console.log(ranks.join("\n")); var file = null; var buffer = new Blob([ranks.join("\n")], {type: 'text/plain'}); var $link = jQuery('<a href="#" download="ranks.properties">Export Ranks</a>').insertBefore('.lia-component-admin-widget-user-rankings'); // If we are replacing a previously generated file we need to // manually revoke the object URL to avoid memory leaks. if (file !== null) { window.URL.revokeObjectURL(file); } file = window.URL.createObjectURL(buffer); $link.attr('href', file); });
of course you would need to tailor the output to your needs, I needed it for rank translation, therefore it is generating the proper text keys to overwrite rank names...
Related Content
- 9 months ago
- 3 years ago
- 8 months ago
- 2 years ago