Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Mentions do not work within a page created via storePage JSON-RPC call

Andrew Stern May 14, 2014

I have a WIP JavaScript to create a page from a series of user inputs. The new page contains a Page Properties macro with several rows, one of which is a list of users. I'd like to format the users as if they were added to the page by a Mention (optimally, I would also like the mentioned users to be notified).

I am submitting the created links as part of the <content> tag in the storePage request. As of right now, I have tried to do this by mimicing the structure of the <a> tag as displayed in this post (https://answers.atlassian.com/questions/97923/how-can-i-get-the-hover-profiles-to-appear-in-my-user-search-plugin), and also by mirroring the structure of the <a> tag from an existing page on which a user was mentioned, so it looks like:

&lt;a class="confluence-userlink user-mention" data-username="the user's username" href="user's relative profile link" data-linked-resource-id="user's ID" data-linked-resource-type="userinfo" data-base-url="Confluence base path URL"&gt;user's full name&lt;/a&gt;

Neither of these options fully works. I can see the user's name and the link to their page, but the hover functionality doesn't work (comes up with "user 'undefined' not found") and the user is not notified. The resulting link looks like this:

&lt;a class="url fn confluence-userlink user-mention userlink-1" href="user's full profile link" rel="nofollow"&gt;user's full name&lt;/a&gt;

For some reason the 'data-linked-resource-id' and 'data-linked-resource-type' properties seem to be removed from the resulting link. Is this what's breaking the hover functionality?

Is there a better way to perform this functionality from a front-end JavaScript? Back-end code isn't an option at this point, and I am not familiar with plugin development.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Chii
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 19, 2014

if you look at a mention in storage format is not an anchor, but a resource identifier for a user. It looks like the 'user' resource, specified on this page https://confluence.atlassian.com/display/DOC/Confluence+Storage+Format#ConfluenceStorageFormat-Resourceidentifiers

Therefore, to trigger a mention, you need to directly create xhtml storage format (which the storePage json rpc call should be able to handle).

E.g.:

&lt;ac:link&gt;&lt;ri:user ri:username="someusername" /&gt;&lt;/ac:link&gt;

Andrew Stern May 22, 2014

I tried this using both a username and an ID (retrieved via the getUserInformation function) and neither seem to work as expected. I'm receiving an error code 500 with a parsing exception that states 'Unexpected close tag </ac:link>; expected </td>.'

The generated code is wrapped in an HTML table and looks something like this:

&lt;tr&gt;&lt;th&gt;Presenters&lt;/th&gt;&lt;td&gt;ac:link&gt;&lt;ri:user ri:userkey="36833446"/&gt;&lt;/ac:link&gt;&lt;/td&gt;&lt;/tr&gt;

TAGS
AUG Leaders

Atlassian Community Events