Display requested item stages in email

AmanPratapS7233
Tera Expert

Hi All,

 

I recently came across a requirement where I have to display the stages of an RITM along with current stage in the email sent to users.

 

For ex - these stages should be added in the email sent to user.

AmanPratapS7233_0-1783394302061.png

 

Suggest me on how can I achieve this ?

 

1 REPLY 1

Danish Bhairag2
Tera Sage

@AmanPratapS7233 

Please follow below steps

 

1. Create a **Mail Script** under *System Notification > Email > Notification Email Scripts*, name it e.g. `ritm_stage_progress`.

2. Paste this script:

 

    var html = '<table cellpadding="4" style="border-collapse:collapse;">';

 

    var stg = new GlideRecord('content_item_stage');

    stg.addQuery('item', current.cat_item);

    stg.orderBy('order');

    stg.query();

 

    while (stg.next()) {

        var isCurrent = (stg.getValue('name') == current.getValue('stage'));

        html += '<tr><td style="' 

              + (isCurrent ? 'font-weight:bold;color:#1a6ed8;' : 'color:#888;')

              + '">' + (isCurrent ? '➤ ' : '&nbsp;&nbsp;&nbsp;')

              + stg.getDisplayValue('name') 

              + (isCurrent ? ' (Current)' : '')

              + '</td></tr>';

    }

    html += '</table>';

 

    template.print(html);

 

 

3. In your Notification's email template/message body, add: ${mail_script:ritm_stage_progress}

4. Test on an RITM notification trigger — the current stage will show highlighted in the email.

 

**Note:** the field linking `content_item_stage` to the catalog item may be `item` or `sc_cat_item` depending on your instance version — check the table's dictionary if the query returns nothing.

 

Thanks,

Danish