Answer
By default, a macro only has access to a broad set of general IFS attributes, not attributes from other business objects the document happens to be connected to — but this can be configured: if a document is attached to a Purchase Order (or any other object), attributes from that specific attached object can be made available to the macro through configuration, rather than needing to add a custom read-only field just to surface a value from a related LU. Since a macro is genuinely code (VBScript-based), it can contain as many conditional branches as needed to decide what value to populate based on other field values — this is standard scripting logic, not a special macro-specific feature. Writing macros does require some VBScript knowledge plus familiarity with whatever target application (e.g. Word) is being automated; IFS support/your IFS contact, or specialized DMS-competent partners, can help if that skill isn't available in-house.