Expand my Community achievements bar.

Native PDF: Note @type=other @othertype - is it possible to set language variable text for the @othertype?

Avatar

Level 1

For the standard note types the language variable text is set successfully so it appears in the prefix-content:

 

<div class="note note" data-attr-type="note">
<span class="prefix-content">Note: </span>This is a note of type 'note'</div>

 

But for @TyPe=other  @othertype I get:

 

<div class="other note" data-attr-othertype="respiratory-warning" data-attr-type="other">
<span class="prefix-content">Other: </span>This is a note of type 'other' with othertype set to respiratory-warning</div>

 

The prefix-content is related to @TyPe=other and not @othertype.

 

Is there a way to set the language variable text for each @TyPe=other @othertype combination?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Employee

@Mike-E 

Thank you for your query.

I further checked and found that dynamic prefixing for @othertype values is not supported currently.

I will be raising a Jira ticket requesting the implementation.

 

Thanks 

Prashant 

 

Avatar

Employee

Hi Mike,

This can be achieved by using following javascript in pdf template. Please feel free to edit it further to achieve desired result.


a. Add following javascript to resources for pdf template.

b. Use the added javascript in content div of page layout for the pdf template (as mentioned below).

c. Enable Javascript at preset level and select above template to preset.

d. Generate the pdf.

 

//Javascript
window.addEventListener('DOMContentLoaded', function () {
const elements = document.querySelectorAll('div.other.note[data-attr-othertype]');
elements.forEach(element => {
    const prefixSpan = element.querySelector('span.prefix-content');
    if (prefixSpan) {
        prefixSpan.textContent = element.getAttribute('data-attr-othertype') + ': ';
    }
});
});
//Add js to content div in Page Layout
<div data-region="content">
    <script src="a.js" type="text/javascript"></script>
  </div>

 

Please let me know if this works for you.

 

Regards,

Tulika Aggarwal