i
Examples of SDK Use
In this SDK use example, a rule is executed to add a new comment in a restaurant app.
It consists of associating an onClick function with a comment button, and its objective is to execute a rule to add a comment about the application.
The rule parameters are obtained from an input element entered by the logged-in user and from a page parameter.
After executing the rule, the callback method is triggered where the result is processed. If there is no error, it clears the value of the input element and updates the repeater iterating over the comments.
function inputComment_onClick(event) { const comment = $d.getInput("newComment").getValue(); const user = $d.getCurrentUser().getUsername(); const idMenu = $d.getParameter("idMenu").getValue(); $d.executeRule("menuCommentSDK", 1, { commentDescription: comment, nameUser: user, menu: idMenu, }, callback);
function callback(result, error) { $d.getInput("newComment").setValue(""); $d.getRepeater("repeater1").refreshRepeater(); } }
|