76
Views
6
Comments
Add comment to Specific Record

Hello Everyone,

I have a Invoice screen in which I have comment button,

when i click on any comment button of any invoice its creates comment on first invoice only.

I'm totally confused what to do

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Dev Limbachia,

can you share what exactly you do to add a comment ? Is it a popup, do you go to another screen, what is the flow when user saves a comment ?

At some point, you need to attach the comment to the row you clicked the button in.  

When you click a button in a row, in the action that is attached to that button, you can refer to the current item, and that will be the row you clicked in.

In any later actions, such as the save button on a popup, that is not the case, at that point, the current has reverted back to the first item of the list.

So, in the action attached to the button, you have to somehow 'remember' the current id of the invoice.  Let's say you have a local variable of type invoiceComment, with the text of the comment as an textarea on your popup, and having a reference to invoice as one if its attributes, you already have to set the invoice reference id in the action attached to your button in your list, and then open the popup.

Dorine

UserImage.jpg
Dev Limbachia

this is my flow and yes it is a popup I've used in the comment button.


2021-09-06 15-09-53
Dorine Boudry
 
MVP

Ok,

so your problem is there at the top right :

GetUserCommentsByInvoiceId.List.Current.UserComments.InvoiceId

= GetInvoiceById.Current.Invoice.Id

In the save of your popup, the 'current' is no longer the clicked row, you have to 'remember' the clicked row between opening the popup and this point, and use that remembered value instead of the current.

Dorine

apart from this, I'm not really understanding all you are doing here, looks a bit funky to me

  • are you saving comment text twice ?  Once in a comment record attached to the invoice and then again as an attribute of invoice ?  Why ?
  • you use views of an aggregate retrieving an comment, but then you always do a create ?  What is intention users can never update comments, every change creates a new record ? why ?  what do you do with all the previous comments, you only show one in the UI ?
  • Why do you have 2 GetInvoiceById aggregates ?  probably a naming matter, the first one is probably not by id, but GetInvoices (as source of the list, so not by id) ?
  • UserComments : it is confusing to use a plural in an entity name
UserImage.jpg
Dev Limbachia

Hello,

I got an another way to for my query, so I thought to share.

Firstly my button was not working on same Invoice screen, so i created another screen name Comment and passed Input parameter of the Invoice entity, and on Invoice screen that button which takes me to Comment screen, i passed the argument of current Invoice.Id

UserImage.jpg
Dev Limbachia

Hello Dorine,

I would like to reply your queries,

Firstly, I need to create comments every time, because on same invoice I want the outstanding such as, when bill was passed and when the payment will come etc. so I also wanted to keep my past comments on that Invoice.

My visual was, when the person opens the Invoice screen, then they should see what is the status of that invoice on screen itself, and when click on invoice detail then it should see all details and timelines.

Secondly, I just made the two Invoices aggregates for my testing purpose nothing much.

and Surely the entity name Usercomments because there will be more than one comments on a particular Invoice.

I hope I was able to clear your doubts and thank you for helping me also :) .

UserImage.jpg
Dev Limbachia

And yes, sorry I forgot to clear your first doubt, 

As I wanted to show the latest comment in invoice screen so I created attributes in Invoice itself. So whenever a user creates a new comment then it will automatically gets updated in Invoice Screen. I kept 'CreateUsercomments' action and other 'UpdateInvoice' action 

(I was unable to use Usercomments entity to show the latest comment so I tried this way, there was a way of creating a block and displaying but I also wanted sorting on comments and Date so I had to create attributes in Invoice.)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.