1- If your question just about hiding the Payment History Button (The Blue One) and only based on if there is an association with the Invoices Entity, the visibility option should done the work for you only check you expression should be like this:
$currentObject/MyFirstModule.invoices_invoicePayments != empty
(The currentObject is Invoices object)
As long as the button inside the Invoices object
Then add your expression to be true or false
and you should get what you wanted
2- If you are trying to check on an attribute in the InvoicePayments to show the button you need to pass the object of InvoicePayments to it, in this case you need a Data View that gets it’s data source from Microflow and pass the Invoices object to that microflow.
then retrieve (Simple Retrieve Activity) the InvoicePayments based on association with the Invoices and return it’s object to the Data View,
then the visibility option expression should be something like this:
$currentObject/data != empty
(The currentObject is InvoicePayments object)
and you also should get what you needed
I hope I’ve helped and that’s what you wanted
It sounds like you have already tried Mohammed’s suggestion, but it just ended up being too slow.
However, this sounds like an attribute that could be added to your Invoice entity, as you would probably eventually want to be able to check whether or not its been paid in a number of places.
If you can identify a certain process where an invoice will be paid, I would create a ‘Paid’ (or whatever makes sense) boolean attribute to the Invoice and set that when that process executes. One way to do this would be to add an After Commit event to the Invoice Payment entity, which then sets that Paid attribute if the Invoice Payment has the proper data. Or, you could set this in a microflow that gets executed when the Invoice Payment goes through. Wherever makes sense.