cjdinger
8 years agoLeader
Endpoint / method to post a reply to a message
New users to our community often post questions that are incomplete -- not enough detail for our expert users to post a meaningful reply. I would like to implement a "Needs more info" button that ou...
- 8 years ago
cjdinger -
Here is the basic script which you use to call an endpoint. You will need to change the button-id and EndpointURL.
<@liaAddScript> ;(function($) { $(document).ready(function(){ $("button-id").click(function(){ $.post("EndpointURL", {'thread-id':"${page.context.thread.topicMessage.uniqueId}", function(status,data){ location.reload(); }}) }) }) })(LITHIUM.jQuery); </@liaAddScript>
jQuery helpful links:
https://www.w3schools.com/jquery/ajax_post.asp
https://www.w3schools.com/jquery/event_click.asp
On the Endpoint side.
<#assign messageID = http.request.parameters.name.get("thread-id","")> <#if messageID != ''> <#assign templateMessage = "This is boilerplate reply" /> <#attempt> <#assign restapi = restadmin("/messages/id/${messageID}/reply?message.body=${templateMessage?url}") /> <#recover> error in all </#attempt> </#if>
Endpoints helpful links:
https://community.lithium.com/t5/Components-endpoints-and-the/About-endpoints/ta-p/108971
https://community.lithium.com/t5/Developer-Knowledge-Base/Working-with-Endpoints/ta-p/60240
This is the just very basic example how you can achieve this. You may add validations to jquery and endpoint.