Use case: when attachments are uploaded/added to a lead or opportunity record in a Dynamics 365 / Power Apps portal, a user wants to receive a notification by email. According to the settings attachments are added as Notes records to CDS. So we need to restrict the On Create trigger by setting the following trigger conditions:
@equals(triggerOutputs()?['body/isdocument'],true) @equals(substring(triggerOutputs()?['body/notetext'],0,5),'*WEB*') @not(empty(intersection(createArray('lead', 'opportunity'), createArray(triggerOutputs()?['body/objecttypecode']))))
So the trigger conditions will check if the note record is a document (file), and if the note description begins with the portal prefix ‘*WEB*’. A third condition will check whether the value of the objecttypecode attribute (similar to the regarding objectid type attribute) is part of a “list” of entities for what the trigger is needed, in this case lead and opportunity.
@contains(createArray('lead', 'opportunity'), triggerOutputs()?['body/objecttypecode'])