Access to the number of likes and comments of an IFTTT created page

Amir August 21, 2021

Hi. How could I access to the number of likes and comments of an IFTTT created page?

For example I have a form that creates a page after submit and the page's ID is ${iftttResult_AAA.id} and it is saved on a field named "KPageID". Now I want to access the number of likes and comments of this page to show it on the cleanView macro. Something like KPageID.likecounts . Thanks

1 answer

1 accepted

3 votes
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2021

ConfiForms provides access to AbstractPage object, but unfortunately it does not provide any information about the "likes" or "comments"

Amir August 22, 2021

yes, you're right. But it would be great if you could show me a creative way to access to likes and comments of created page in view macro. I try page properties but it didn't work.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2021

Page properties will not work, as these "objects" are not page properties...

Creative way? :-)

Of course it is possible with ConfiForms - you can use, for example, Web service Object ref field type

(I have a web-service connection configured to my local instance of Confluence and use REST APIs to get other pages metadata that can be retrieved). Important to set the field to have "as proxy" parameter checked

http://recordit.co/1VtKmFhzo3

Transforming a bit results what I get from the REST API endpoints

<ac:structured-macro ac:macro-id="a3724955-6510-4fc1-9341-321fbf97df88" ac:name="confiform" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<ac:structured-macro ac:macro-id="2b99e58c-d835-4a4e-992b-704cba1ae545" ac:name="confiform-entry-register" ac:schema-version="1">
<ac:parameter ac:name="type">Embedded</ac:parameter>
<ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
<ac:rich-text-body>
<p>
<br/>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<ac:structured-macro ac:macro-id="a0b8b1c5-1a9c-48af-a005-e20ca975891a" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">p</ac:parameter>
<ac:parameter ac:name="fieldLabel">page</ac:parameter>
<ac:parameter ac:name="type">page</ac:parameter>
</ac:structured-macro> </p>
<p>
<ac:structured-macro ac:macro-id="ca220efd-3c8f-498e-a1ef-2f66fae4f3c5" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="fieldName">likes,comments</ac:parameter>
<ac:parameter ac:name="action">Hide field</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="5dc2db31-3c22-4bd4-b9c6-94e7adc2b520" ac:name="confiform-field-definition-rules" ac:schema-version="1">
<ac:parameter ac:name="condition">!p:[empty]</ac:parameter>
<ac:parameter ac:name="values">likes=[entry.p]&amp;comments=[entry.p]</ac:parameter>
<ac:parameter ac:name="action">Set value</ac:parameter>
<ac:parameter ac:name="actionFieldName">p</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="519e5e4f-190c-4104-8c2a-7f7256f0b632" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="mapping">||undefined</ac:parameter>
<ac:parameter ac:name="fieldName">likes</ac:parameter>
<ac:parameter ac:name="fieldLabel">Likes</ac:parameter>
<ac:parameter ac:name="values">rest/likes/1.0/content/[entry.likes]/likes</ac:parameter>
<ac:parameter ac:name="extras">cfa616dd12ec3374aa15e100bd9e20be</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">objectRef</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="3aca9e4e-6802-4290-83cf-d706cf250eaa" ac:name="confiform-field-definition" ac:schema-version="1">
<ac:parameter ac:name="fieldName">comments</ac:parameter>
<ac:parameter ac:name="fieldLabel">Comments</ac:parameter>
<ac:parameter ac:name="values">rest/api/content/[entry.comments]?expand=children.comment</ac:parameter>
<ac:parameter ac:name="extras">cfa616dd12ec3374aa15e100bd9e20be</ac:parameter>
<ac:parameter ac:name="extracontext">true</ac:parameter>
<ac:parameter ac:name="type">objectRef</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>
<p>
<br/>
</p>
<p>
<br/>
</p>
<ac:structured-macro ac:macro-id="68260d60-a850-41e8-8a81-b06898927bf6" ac:name="confiform-table" ac:schema-version="1">
<ac:parameter ac:name="formName">f</ac:parameter>
<ac:rich-text-body>
<p>
<ac:structured-macro ac:macro-id="3e9838f8-6b1c-42ae-866a-5a00899f9ad6" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">p</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="809ed2c0-4f9e-47a9-a18a-f615b7b0f8c6" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">likes.likes.asJSON.transform(user).asCount</ac:parameter>
</ac:structured-macro>
</p>
<p>
<ac:structured-macro ac:macro-id="e6c94b5d-c87b-4d36-9d8f-d3456bd626c5" ac:name="confiform-field" ac:schema-version="1">
<ac:parameter ac:name="fieldName">comments.children.comment.results.asJSON.asCount</ac:parameter>
</ac:structured-macro>
</p>
</ac:rich-text-body>
</ac:structured-macro>

Alex

Like Amir likes this
Amir August 23, 2021

That was creative :)
But I don't know how to make a web service. I know that I should configure it in confiform configuration page but I don't know how to program a web service. However thanks for your solution. If I could build a web service, I will test it.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2021

You dont have to build/develop a webservice!

All I do here is I use the public REST APIs that your Confluence instance has.

I have just set up a connection to help web-service backed fields to use it - more on such group of fields https://wiki.vertuna.com/display/CFWEB/Working+with+web+services+backed+fields 

Like Amir likes this
Amir August 23, 2021

I get it. Thanks a lot.

And the page you sent is in a private space and I should login to see that.

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 23, 2021
Like Amir likes this
Amir August 23, 2021

Excellent. You're the best developer :) Thank you very much
I hope I could do it with these instructions.

Amir August 26, 2021

I've pasted the source code you've sent on an empty page and it didn't work. (Likes and comments in view table are empty after adding a page to this form and the values of likes and comments are id of the page I entered.)

Sorry to ask again. Should I configure any web-service in confiform configuration page? Or web-service connection field in my form should be empty?

Untitled.png

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 26, 2021

Of course you need to configure connection to your confluence and select it here, in the field configuration

it is visible in my screencast, and I mentioned it in my comments

see other tutorials I have linked to see where this connection needs to be configured

Like Amir likes this
Amir August 27, 2021

I'm so sorry but I couldn't understand how to configure web-service connection in confiforms configuration page. unfortunately I couldn't see this page you sent:

https://wiki.vertuna.com/display/CFWEB/Working+with+web+services+backed+fields

and in other URLs you sent there is no guidance to show how configure webservice connection. I search on google but find nothing. could you just say what should I write in these fields to connect to confluence rest api? thanks again.

Untitled.png

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2021

In WS URL put your server URL... with https:// or http://

Does not have to be named "confluence cloned" - this is up to you

Like Amir likes this
Amir August 28, 2021

Thank you again. I was finally able to do it.

But I have a question. When the form submitted, a page created and for access the likes and comments of that created page, I should have the ID of that page and I couldn't set value while submitting the form. So should I create another form when IFTTT runs and set values on that form or there is no need to create another form and I could set value of likes and comments with IFTTT created page ID while submitting the form? I ask because I try some ways and I couldn't succeed. Thanks

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2021

You can save back the page id of a created page (for both, the likes and the comments field)

Solution on the right of the page - https://wiki.vertuna.com/display/CONFIFORMS/Creating+links+in+original+ConfiForms+entry+to+just+created+page

(where we set back the page id, not the link)

Alex

Like Amir likes this
Amir August 28, 2021

I'm so sorry for these many questions, but I try many ways and when I do not reach the answer, I have to ask questions...

I had done this way before, but when I'm defining the form and define field definition of likes and comments, I should set value of "/rest/likes/1.0/content/[entry.IFTTTCreatedPageID]/likes" for likes, while it hasn't value yet! So where I should put the "confiform-field-definition-rules" to set value of IFTTTCreatedPageID and then set it in likes and comments?

I hope this will be my last question :D

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2021

Please re-read my previous answer 

You can save back the page id of a created page (for both, the likes and the comments field)


And see the page I have linked... It does not talk about the "confiform-field-definition-rules" macro... 

And my answer tells you that you need to save back the page id to comments and likes field! Do you understand what I am trying to say?

Alex

Like Amir likes this
Amir August 28, 2021

YES, It's DONE

I should just use another IFTTT instead of rules.

I Couldn't have done it without you.

Many thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events