title: BI Publisher conditional field masking
body: <p>I have the following code on a field in a Peoplesoft BI Publisher RTF template where it is masking the last 4 digits of the Bank Account number. </p>
  
  <pre><code>&lt;?xdofx:lpad('',length(Bank_Account__)-4,'*')?&gt; 
  &lt;?xdoxslt:rtrim(xdoxslt:right(Bank_Account__,4))?&gt;
  </code></pre>
  
  <p>The problem is that sometimes the total Bank Account number length is less than 4 digits and when this happens it causes an negative array error on the lpad function to occur. </p>
  
  <p>Can I wrap some kind of conditional IF statement around this where it will check the length of the bank account number and if it is longer than 5 digits than mask the last 4 digits, else (for Bank Account numbers less than 5 digits) just mask the last 2 digits. What would this look like?</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I should add that the existing code above is already wrapped in the following IF statement: </p>
  
  <pre><code>&lt;?if@inlines:Bank_Account__!=''?&gt;
  </code></pre>
  
  <p>So the entire statement is:</p>
  
  <pre><code>&lt;?if@inlines:Bank_Account__!=''?&gt;
      &lt;?xdofx:lpad('',length(Bank_Account__)-4,'*')?&gt; 
      &lt;?xdoxslt:rtrim(xdoxslt:right(Bank_Account__,4))?&gt;
  &lt;?end if?&gt;
  </code></pre>
  
  <p>I would just like to add in the conditional logic to check the bank account length and subsequently perform either of the above masking.</p>
  
  <p><strong>EDIT 2:</strong>
  Here is my setup with your suggested changes, but I don't think I have the logic nested right, and the syntax may also be an issue.</p>
  
  <p><a href="https://i.stack.imgur.com/UbBwt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UbBwt.png" alt="enter image description here"></a></p>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>Here is the modified code, and the resulting error message:</p>
  
  <p><a href="https://i.stack.imgur.com/IIHh2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IIHh2.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/69PZX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/69PZX.png" alt="enter image description here"></a></p>