CA Service Management

 View Only

SPEL: HTML styled notification via SPEL 

Jun 12, 2015 07:12 AM

Document is outdated!

More flexible solution was found: HTML Notifications in a context of custom object. by Karoliss

 

This doc is kept as example how animator_nxd could be used for customers purposes.

 

Original doc:

Today I wish to share my method, which gives possibility, to send html formatted notifications via SPEL.

I've used animator_nxd queue to make this trick works,

so I would be pleased to hear opinions on this and it will be great if someone else have animator customization/usage experience.

 

Why this is needed?

Generally CA SDM have possibility to send notification to any related contact object, OOTB or custom.

But what to do if contact or contacts list are not related with notified object?

For example our business have requirement to notify customers when CO is approved but list of customers is a LREL which filled on previous CO stage.

Here comes to help OOTB method called "notify_list" but it works only with plain text (as OOTB Manual notify function).

 

How this method works?

I have spent a lot of time in tries to premodify that plain text notification but it seems like all realtime notifications are performed by pdm_mail_nxd without any possibility to customize them.

So I have based my method on notification queue table.

Algoritm:

    1. Create queued notification;

    2. Create animator to proceed recently created notification.

 

Usage example

notque::z_create_notify("<p>My <span style='color:red'>beautiful</span> <b>text</b> notification</p>", // HTML body here, 32768 symbols max

                        "RE: Header",                                                       // Notification header
                        "cnt:98F9B596B29349439597C90C17903F46
",                             // recipient UUID
                        "chg:1337",                                                         // object persid
                        29,                                                                 // unknown, 28 for REQ/INC, 29 for others
                        2                                                                   // Notification level: 2 - Normal, 3 - High, etc.   
                        );

 

Entire code is attached as attachment,

any comments, tips and suggestions are welcome!

Statistics
0 Favorited
36 Views
1 Files
0 Shares
6 Downloads
Attachment(s)
zip file
z_crt_ntf.spl.zip   1 KB   1 version
Uploaded - May 29, 2019

Tags and Keywords

Comments

Nov 26, 2015 05:05 AM

Ops wrong code in previous message:

 

object ticket, macro;
send_wait(0, top_object(), "call_attr", "chg", "dob_by_persid", 0, "chg:400892"); 
ticket = msg[0];
printf("Change: '%s' \n", ticket.chg_ref_num); 
send_wait(0, top_object(), "call_attr", "macro", "dob_by_persid", 0, "macro:400261"); 
macro = msg[0];
printf("incident: '%s' \n", macro.msg_tmpl_info.notify_msg_body_html); 

send_wait(0, ticket, "do_expand",macro.msg_tmpl_info.notify_msg_body_html,3);  
if (!msg_error()) {
   int i;   
   for (i=0;i<msg_length();i++) {   
     printf("msg[%d]: '%s'", i, msg[i]);   
   }
}
else{
   
  printf("Error %s",msg[0]);
}

Nov 25, 2015 06:22 PM

thanks,

this method is much better,

im planning to switch to it!

Nov 25, 2015 05:42 PM

In order to generate body for the email standart templates can be used. They can be evaluated by do_expand method:

 

object ticket, macro;

send_wait(0, top_object(), "call_attr", "chg", "dob_by_persid", 0, "chg:400892"); 

ticket = msg[0];

printf("Change: '%s' \n", ticket.chg_ref_num); 

send_wait(0, top_object(), "call_attr", "macro", "dob_by_persid", 0, "macro:400261"); 

macro = msg[0];

if (!msg_error()) {

   int i;   

   for (i=0;i<msg_length();i++) {   

     printf("msg[%d]: '%s'", i, msg[i]);   

   }

}

else{

   

  printf("Error %s",msg[0]);

}

 

msg[0] will contain evaluated template whe @{atribute} will be replaces with attribute value. It is bad that this method is only defined for objects that are available for activity notifications (cr,cnt,chg,iss,wf and etc.)

Nov 25, 2015 01:58 PM

cdtj  please check the following document recently writen by my coleague:

 

https://communities.ca.com/docs/DOC-231163123

Oct 29, 2015 02:15 AM

thanks for sharing!

i'll give a try,

I really dont like the method described in this doc but haven't other

Oct 28, 2015 07:09 PM

There is a method on KD object called send_it. Ofcourse to access it you should pass any existing KD document as the context, thats why i don't like it.

 

 

send_wait(0, top_object(), "call_attr", "KD", "dob_by_persid", 0, "KD:400459"); 

if (msg_error()) { 

printf("Error %s",msg[0]); 

else 

{

object KDO;

KDO = msg[0];

send_wait(0, KDO, "send_it", "servicedesk1@net.local", "test subject", "test plain", "<B>test html</B>"); 

}

//send_it(string email_address, string msg_subject, string msg_body,string msg_html );

Aug 11, 2015 03:23 PM

Nice.

Aug 11, 2015 03:09 PM

Hi cdtj

 

    Thank You for sharing, i linked this document - Where can I find Spel functions documentation?

 

Regards

Tiago

Related Entries and Links

No Related Resource entered.