This worked perfectly except for one thing I wasn't aware of. This was setup as a way to have the latest contract show on an account for the portal, but a contract is several parts. The description was used to state which part each was.
So instead of the layout above
Account
-> Most Recent Contract (created date)
it is being used as
Account
-> Name: "Contract" CreatedAt: 1/1/23
-> Name: "Terms and Conditions" CreatedAt: 1/1/23
-> Etc
Looking at your code and reading through the function instructions (https://docs.espocrm.com/administrat...indrelatedmany) it seems like I should modify your code to add in ", 'name=','Contract'" at the tail end of the findrelatedmany function, like so:
Code:
$relatedEntitiesIds = record\findRelatedMany($entityType, $entityId, $relatedEntitiesLinkName, $relatedEntitiesCount, 'createdAt', 'desc', 'name=', 'Contract');
Your help was invaluable, @lazovic
Leave a comment: