post comments function

saikumarkak
Tera Contributor

saikumarkak_0-1746875831718.png

Ehen i click on post comments button that comment should be populate in activity stream. this is made in ui builder compose is text area and post comments is button area. how can i achieve this 

 

1 ACCEPTED SOLUTION

ShivaBalajPatel
Giga Contributor

Hi, If you want to post a comment and instantly show it in the activity stream in UI Builder, here's a simple way to do it,

Requirements:

  1. Compose – This is your Text Area where users type the comment.

  2. Post Comment Button – Users click this to submit the comment.

  3. Activity Stream – This is where you show the list of comments.

Steps:

  1. Create a View Model Variable
    For example: commentText
    Bind your Text Area value to this variable.

  2. Set Up a Data Resource
    Use a data resource (like sys_journal_field ) to store and show comments.

  3. Configure the Post Comment Button
    Add an event to this button:

    • Create a new comment record using the value from commentText.

    • After posting, clear the input and refresh the data.

    Example:

     
$data.CommentTable.createRecord({
  element_id: '<record sys_id>',
  element: 'comments',
  value: viewModel.commentText
}).then(() => {
  viewModel.commentText = '';
  $data.CommentTable.reload();
});

     4. Show Comments in Activity Stream
         Use a Repeater to loop through CommentTable.records and display each comment.

That’s it! Now when someone types a comment and clicks the button, it gets saved and shows up right away in the activity stream.

Let me know if you want help with any step!

View solution in original post

1 REPLY 1

ShivaBalajPatel
Giga Contributor

Hi, If you want to post a comment and instantly show it in the activity stream in UI Builder, here's a simple way to do it,

Requirements:

  1. Compose – This is your Text Area where users type the comment.

  2. Post Comment Button – Users click this to submit the comment.

  3. Activity Stream – This is where you show the list of comments.

Steps:

  1. Create a View Model Variable
    For example: commentText
    Bind your Text Area value to this variable.

  2. Set Up a Data Resource
    Use a data resource (like sys_journal_field ) to store and show comments.

  3. Configure the Post Comment Button
    Add an event to this button:

    • Create a new comment record using the value from commentText.

    • After posting, clear the input and refresh the data.

    Example:

     
$data.CommentTable.createRecord({
  element_id: '<record sys_id>',
  element: 'comments',
  value: viewModel.commentText
}).then(() => {
  viewModel.commentText = '';
  $data.CommentTable.reload();
});

     4. Show Comments in Activity Stream
         Use a Repeater to loop through CommentTable.records and display each comment.

That’s it! Now when someone types a comment and clicks the button, it gets saved and shows up right away in the activity stream.

Let me know if you want help with any step!