Include ram:RoleCode no more than once

Error FX-SCH-A-000710 Factur-X

Element 'ram:RoleCode' may occur at maximum 1 times.

Mandatory rule: As long as it is violated, the invoice is invalid and will be rejected by validators.
What is wrong

The ram:ProductEndUserTradeParty contains more than one ram:RoleCode element.

What the rule means

ram:RoleCode is optional in this party element but may occur only once. Multiple role codes at this location do not conform to the required structure.

Please include the product end user’s role code no more than once

ram:RoleCode appears multiple times in ram:ProductEndUserTradeParty. The role code may appear at most once in this element.

What to do
  1. Find the relevant ram:ProductEndUserTradeParty.
  2. Remove any extra ram:RoleCode elements there, or omit ram:RoleCode if no role code is to be provided.
  3. Generate the invoice again and validate it once more.
What it looks like
✗ Triggers the message
<ram:ProductEndUserTradeParty>
  <ram:RoleCode>1</ram:RoleCode>
  <ram:RoleCode>2</ram:RoleCode>
</ram:ProductEndUserTradeParty>
✓ Correct
<ram:ProductEndUserTradeParty>
  <ram:RoleCode>1</ram:RoleCode>
</ram:ProductEndUserTradeParty>
Technical details

The test counts the direct ram:RoleCode elements in the current ram:ProductEndUserTradeParty and allows no more than one.

Where the rule applies

The rule applies to ram:RoleCode within ram:ProductEndUserTradeParty in the invoice agreement.

Context (rule/@context)
/rsm:CrossIndustryInvoice/rsm:SupplyChainTradeTransaction/ram:ApplicableHeaderTradeAgreement/ ram:ProductEndUserTradeParty
Test expression (assert/@test)
count(ram:RoleCode)<=1