Hello Team,
What will be the simple and easiest solution to implement a comment section for each request. I was thinking to create comment record table with comment text, comment by, comment date and requestId which will be linked to my main tables with one to many relationship. Then create interface with one button which stores all that information in rule input pass it to the process model and then for each of these comments which are associated with the request id to pull them in the interface? Is that something possible not sure how to implement this or if there is any simple approach. I was thinking that I won't be able to use any notification like that, since preferred method would be to send notification to the users which was already commented the request or at least to the person who requested it, since I have requestor field in my main table which store the request information. Thanks for all suggestions!
Discussion posts and replies are publicly visible
HiShwapx ,
It is possible you can have a common comments table with request id. If you store the data in that manner you can query the comments of that particular request at any time and can show in the interface.
So in the interface I need to be able to post new comments and in the same time pull out old comments related to that request with the requestid. It has to be a related action. Can you help me build example interface? I was trying this code, but nothing happened.
a!localVariables( local!newComment: "", a!headerContentLayout( header: {}, contents: { a!columnsLayout( columns: { a!columnLayout(contents: {}), a!columnLayout( contents: { a!sectionLayout( label: "Comments Section", labelSize: "LARGE", labelColor: "STANDARD", contents: { /* Add Comment Section */ a!sideBySideLayout( items: { a!sideBySideItem( item: a!imageField( label: "", labelPosition: "COLLAPSED", images: { a!webImage( source: "https://randomuser.me/api/portraits/men/1.jpg" /* Placeholder for the logged-in user's avatar */ ) }, size: "TINY", isThumbnail: false, style: "AVATAR" ), width: "MINIMIZE" ), a!sideBySideItem( item: a!paragraphField( label: "Post a Comment", labelPosition: "COLLAPSED", placeholder: "Type your comment here...", value: local!newComment, saveInto: local!newComment, refreshAfter: "UNFOCUS", height: "MEDIUM" ) ) }, alignVertical: "TOP" ), a!buttonArrayLayout( buttons: { a!buttonWidget( label: "Post Comment", style: "SOLID", saveInto: { a!writeRecords( records: { a!map( recordType: 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments', fields: { 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{7477677e-4205-46cb-bf86-eef4b281ded1}commentText': local!newComment, 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{f6a96e69-627b-4acf-bac0-9a518edbba55}commentedBy': loggedInUser(), 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{9cdf10da-c7bd-4699-b291-b3be3b6aeedd}commentDate': now(), 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{922dc3c8-a3e8-46fb-b4e1-4a06be1255e3}requestId': ri!requestId } ) }, onSuccess: { a!save(local!newComment, ""), a!save( ri!AOS_Comments, a!queryRecordType( recordType: 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments', filters: a!queryFilter( field: 'recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{922dc3c8-a3e8-46fb-b4e1-4a06be1255e3}requestId', operator: "=", value: ri!requestId ), pagingInfo: a!pagingInfo( startIndex: 1, batchSize: 10 ) ).data ) } ) } ) }, align: "END", marginBelow: "MORE" ), /* Display Comments Section */ a!forEach( items: ri!AOS_Comments, expression: a!sideBySideLayout( items: { a!sideBySideItem( item: a!imageField( label: "", labelPosition: "COLLAPSED", images: { a!webImage( source: "https://randomuser.me/api/portraits/men/1.jpg" /* Placeholder for user's avatar */ ) }, size: "TINY", isThumbnail: false, style: "AVATAR" ), width: "MINIMIZE" ), a!sideBySideItem( item: a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextItem( text: { fv!item['recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{f6a96e69-627b-4acf-bac0-9a518edbba55}commentedBy'] }, style: { "STRONG" } ), char(10), fv!item['recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{7477677e-4205-46cb-bf86-eef4b281ded1}commentText'], char(10), a!richTextItem( text: text(fv!item['recordType!{624eb116-a5d3-4311-b161-fe174dcd7b79}AOS_Comments.fields.{9cdf10da-c7bd-4699-b291-b3be3b6aeedd}commentDate'], "MMM d, yyyy h:mm a"), color: "SECONDARY", size: "SMALL" ) } ) ) }, alignVertical: "TOP", marginBelow: "MORE" ) ) } ) }, width: "WIDE" ), a!columnLayout(contents: {}) } ) }, backgroundColor: "WHITE" ) )
Any help?
Your code has only write records you can post the comments. If you want to view the old comments have a queryrecord() with requestid filter and show them before the new comments field.
How exactly I need to show them. Since I was thinking I'm doing that with for each but it's not working, and the problem is that even the write record is not writing in the database the request id should come from my main table as related action when I enter in my record.