Conditional display of text based on field value

Hi,

I have an org chart where we display incumbent employees as well as temporary actors. Each employee (up to 3 in one box) has a tenure that should be displayed next to their name. So for example, if FIELD_TENURE contains text a or text b I would like to display "casual" next to their name. If on the other hand the field contains other text I would like to display some other text.

So in the box for a position that has an incumbent and an actor currently assigned, I would show:

Employee Name 1 (Appointed)

Employee Name 2 (Casual)

Hi @Marc_G,

There are a few options for this.

The most straightforward approach is to use the template editor to include the field value. This works well when you are simply displaying the literal text from the item.

For example, in this case, we only show the office when the value is not empty:

If you need to add some additional logic and pre-process the information, we can use some custom code instead.

For example, the following snippet checks whether the job title contains the term “Chief” and adds some text next to the name:

api.onBoxRendered((box, itemData)=> {
        const $node =$(box.elem) .closest('.poch-group-item') .find('.poch-box__header');
        const customTag=itemData['JobTitle'].contains('Chief') ? '(Text A)' : '(Text B)';
        $node.append("<div>" +customTag+" </div>")
    });

Feel free to try either option, depending on your use case, and let me know how it goes.

Best regards,
Milagros
Plumsail team