Clarity Service Management

Expand all | Collapse all

Store Mail address in incident field in case of maileater

Jump to Best Answer
  • 1.  Store Mail address in incident field in case of maileater

    Posted 06-28-2018 03:29 AM

    We have configured maileater for incident creation from email in CA service Desk. Mails from unknown mail address are created under anonymous user.  Is it possible to store from_mail in any of the incident fields (eg. summary or external system ticket)?

    This will help in viewing mail address quickly from incident page.

    We tried rule such as INCIDENT.summary=%FROM_EMAIL%, but it is not working.

    Kindly share suitable solution.



  • 2.  Re: Store Mail address in incident field in case of maileater

     
    Posted 06-28-2018 09:27 AM


    Hi Abinash,
    What is value "Attach Entire Email" field in the Mailbox Detail?
    Also, what version of Service Desk are you using?

    Here is the community post  CA Tuesday Tip: Maileater: to attach or not to attach  about the fields "Attach Entire Email", "Force Attachment Splitout", "Allow Anonymous", etc. in the Mailbox detail. Although it mentioned Service Desk 12.6, it still valid in 14.x and 17.x.

    Regards,
    Derek



  • 3.  Re: Store Mail address in incident field in case of maileater

    Posted 06-28-2018 11:18 AM

    Analyst team needs mail address to be stored in any incident field so that quickly they can view mail address. Attaching whole mail does not meet requirement as opening attachment for every incident create delay in responding. We can't recommend to open attachment only for viewing mail address. Is there a way to store mail address in fields like summary or external system ticket. 



  • 4.  Re: Store Mail address in incident field in case of maileater

    Posted 06-28-2018 11:17 AM

    Analyst team needs mail address to be stored in any incident field so that quickly they can view mail address. Attaching whole mail does not meet requirement as opening attachment for every incident create delay in responding. We can't recommend to open attachment only for viewing mail address. Is there a way to store mail address in fields like summary or external system ticket. 



  • 5.  Re: Store Mail address in incident field in case of maileater

     
    Posted 06-28-2018 01:41 PM

    Because the sender email address (anonymous user) is not tied with a Service Desk contact, maileater could auto include sender email  address in the Summary or Description like Created via EMAIL interface by John.smith@xyz.com

     

    The user can state sender email in %Description=My email address is John.Smith@xyz.com. I have problem...



  • 6.  Re: Store Mail address in incident field in case of maileater

    Posted 06-30-2018 10:14 AM

    In our case, Created via EMAIL interface by John.smith@xyz.com in not appearing in description/summary. It is only appearing under INITIAL activity log. Therefore we are searching for a solution to log mail address in summary/any other incident field. Please suggest suitable solution.

     

    We can't tell end user to mention %Description=My email address is John.Smith@xyz.com as endusers are anonymous.



  • 7.  Re: Store Mail address in incident field in case of maileater

    Posted 06-30-2018 11:46 AM

    Hi,

     

    If you have CA Process Automation you could have an event fired on Inital when Created_Via is the email interface. The Pam process can get the email address from the initial activity log and then update the external system ticket or description.



  • 8.  Re: Store Mail address in incident field in case of maileater

    Posted 06-30-2018 12:54 PM

    Hello Grant,

     

    We are not using PAM. Is it possible to use global variable such as "$FROM_USERID, $FROM_EMAIL, $FROM_EMAIL_OVERRIDE in text,api to capture mail address? Kindly suggest any other way.



  • 9.  Re: Store Mail address in incident field in case of maileater

     
    Posted 07-02-2018 02:53 AM

    One option would be to add an event to the Initial activity notification, which would launch a macro to extract the email from the text of the INIT activity log description, and store the email in a field in the CR.  If you're interested in pursuing that alternative I can provide more details about how to implement it.

    Regards,

    James



  • 10.  Re: Store Mail address in incident field in case of maileater

    Posted 07-02-2018 03:34 AM

    Thanks a lot James for this solution. This will meet our requirement. Kindly provide us the steps and scripts to be used for achieving this.



  • 11.  Re: Store Mail address in incident field in case of maileater

     
    Posted 07-02-2018 04:49 AM

    Here is the body of an Action macro on the 'cr' object that I hope does more or less what you are looking for.  I've used a custom field 'zFrom' as the destination for the 'from email' address - you will need to add this as a custom field and set its length conservatively, as email addresses can be quite long.  In my 'sandbox' environment, maileater writes '%FROM_EMAIL=<the email address>' as the last entry in the activity log description, so I've taken the email address as being any text from the end of that label to the end of the description.

        
        // Requires the CR to be locked.
        string method;
        method="zcrSetzFromFromINITAlg";

        object alg_list;
        object theAlg;
        int alg_count;
        int alg_index;

        int idxFrom;
        string sFrom;
        string theFROMlabel;
        theFROMlabel = "FROM_EMAIL=";
        // Find the INIT alg for this CR and get its description.

        // If the description doesn't start with 'created via email interface by',
        // the sync_fetch won't get any records. If so, quit.
        send_wait(0, top_object(), "call_attr", "alg", "sync_fetch", "RLIST_DYNAMIC",
         format("call_req_id='%s' and type='INIT' and description like 'created via email interface by %'",
         this.persistent_id), 1, 0);

        if (msg_error())
        {
         logf(ERROR, "%s: Error on sync_fetch for INIT ALG for %s", method, this.persistent_id);
         return;
        }

        alg_list = msg[0];
        alg_count = msg[1];
        if (alg_count <= 0)
        {
         logf(SIGNIFICANT, "%s: no INIT alg for email interface for %s", method, this.persistent_id);
         return;
        }

        // Get the first (and should be the only) INIT with an email description
        alg_index = 0;
        send_wait(0, alg_list, "dob_by_index", "DEFAULT", alg_index, alg_index);

        if (msg_error())
        {
         logf(ERROR, "%s: Error on dob_by_index for INIT ALG for %s, index %d: %s",
         method, this.persistent_id, alg_index, msg[0]);
         return;
        }

        theAlg = msg[0];
        string theDesc;
        theDesc = theAlg.description;
        // Find the FROM_EMAIL= label
        idxFrom = sindex(theDesc, theFROMlabel);
        if (idxFrom >= 0)
        {
         sFrom = substr(theDesc, idxFrom + strlen(theFROMlabel));
         this.zFrom = sFrom;
        }
        else
        {
         logf(ERROR, "%s: FROM_EMAIL not found in INIT ALG for %s", method, this.persistent_id);
         return;
        }
    Are you aware of how to create a new action macro?  If not, here is a quick checklist:
    • Use pdm_extract to extract an existing 'cr' action macro as a text file from the Spell_Macro table.
    • Find and remove the 'id' and 'persid' entries in the field list below the header 'TABLE Spell_Macro' and remove the corresponding fields from the macro definition.
    • Change the description and 'sym' appropriately.  In my example above 'sym' becomes 'zcrSetzFromFromINITAlg'.
      Delete the text between the double quotes in the 'fragment' field.
    • Replace the 'fragment' text with the text above.
    • Replace all 'double quote' characters in the above (apart from the two that delimit the fragment field itself) with 'backslash double quote'.
    • Replace all line feeds with '\\0012', so that the 'fragment' occupies a single line in the text file.
    • Save as a text file with a suitable name.
    • Use pdm_load -ivf filename to load the new macro.  The flag '-i' causes a new record to be inserted.
    • Note the new identifier that pdm_load reports - e.g. 'macro:400005'
    • When you need to edit the macro, extract it from Spell_Macro and edit the extracted copy.  Save as a text file again but this time use 'pdm_load -vf filename' to update rather than insert.

     

    Having created this new macro, you can add an Event to the Initial Activity Notification for Requests / Incidents / Problems, and select the macro as the 'Action on True' in the event.

     

    Please post back if you're having any trouble with any of this.

     

    Regards,

    James



  • 12.  Re: Store Mail address in incident field in case of maileater

    Posted 07-03-2018 12:04 AM

    Hello James,

    Thanks a lot for sharing the code. While load getting error in theFROMlabel line as "ERROR: Invalid row termination, expected }
    SP0E62~1.TXT 10 \\0012 theFROMlabel = \"FROM_EMAIL=\";\\0012" .

    Import file is as follows:

    TABLE Spell_Macro
     del description fragment last_mod_by last_mod_dt lock_object msg_html
     msg_tmpl_info ob_type sym tenant type usr_integer1 usr_integer2 usr_integer3
     usr_string2 usr_string3 usr_string4
     { "0" ,"set mail address in summary field","string method, sFrom, theFROMlabel;\\0012
    \\0012 method=\"zcrSetzFromFromINITAlg\";\\0012
    \\0012 object alg_list;\\0012
    \\0012 object theAlg;\\0012
    \\0012 int alg_count, alg_index, idxFrom;\\0012
    \\0012 theFROMlabel = \"FROM_EMAIL=\";\\0012
    \\0012 send_wait(0, top_object(), \"call_attr\", \"alg\",\\0012 \"sync_fetch\", \"RLIST_DYNAMIC\", format(\"call_req_id='%s' and \\0012 type='INIT' and description like 'created via email\\0012 interface by %'\", this.persistent_id), 1, 0);\\0012
    \\0012 if (msg_error())\\0012
    \\0012 {\\0012
    \\0012  logf(ERROR, \"%s: Error on sync_fetch for INIT ALG for %s \\0012\", method, this.persistent_id);\\0012
    \\0012  return;\\0012
    \\0012 }\\0012
    \\0012 alg_list = msg[0];\\0012
    \\0012 alg_count = msg[1];\\0012
    \\0012 if (alg_count <= 0)\\0012
    \\0012 {\\0012
    \\0012 logf(SIGNIFICANT, \"%s: no INIT alg for email interface \\0012 for %s\", method, this.persistent_id);\\0012
    \\0012 return;\\0012
    \\0012 }\\0012
    \\0012 alg_index = 0;\\0012
    \\0012 send_wait(0, alg_list, \"dob_by_index\", \"DEFAULT\",\\0012 alg_index, alg_index);\\0012
    \\0012 if (msg_error())\\0012
    \\0012 {\\0012
    \\0012 logf(ERROR, \"%s: Error on dob_by_index for INIT ALG for \\0012 %s, index %d: %s\", method, this.persistent_id, \\0012 alg_index,msg[0]);\\0012
    \\0012 return;\\0012
    \\0012 }\\0012
    \\0012 theAlg = msg[0];\\0012
    \\0012 string theDesc;\\0012
    \\0012 theDesc = theAlg.description;\\0012
    \\0012 idxFrom = sindex(theDesc, theFROMlabel);\\0012
    \\0012 if (idxFrom >= 0)\\0012
    \\0012 {\\0012
    \\0012 sFrom = substr(theDesc, idxFrom + strlen(theFROMlabel));\\0012
    \\0012 this.summary = sFrom; \\0012
    \\0012 }\\0012
    \\0012 else\\0012
    \\0012 {\\0012
    \\0012 logf(ERROR, \"%s: FROM_EMAIL not found in INIT ALG for %s\", method, this.persistent_id);\\0012
    \\0012 return;\\0012
    \\0012 }","" ,"" ,"1" ,"" ,"" ,"cr" ,"zcrSetzFromFromINITAlg" ,"" ,"ACT" ,"" ,"" ,"" ,"" ,"" ,"" }



  • 13.  Re: Store Mail address in incident field in case of maileater

     
    Posted 07-03-2018 03:16 AM

    The macro code must be all on one line.  To see the correct format, try exporting an out-of-the-box macro like "Notify end User's Org".  The code is displayed like this:

     

    ...but when exported it is formatted with the macro code all on one line (scroll to the right):

    TABLE Spell_Macro
        del description fragment id last_mod_by last_mod_dt lock_object msg_html
        msg_tmpl_info ob_type persid sym tenant type usr_integer1 usr_integer2 usr_integer3
        usr_string2 usr_string3 usr_string4
        { "0",
        "send notification to Affected End User's organization primary contact",
        "string evt_mtitle, evt_mbody;\\0012evt_mtitle = find_msg(63, 28, chg_ref_num, event_tmpl.condition.sym);\\0012evt_mbody = find_msg(63, 24, chg_ref_num);\\0012evt_mbody += find_msg(63, 25, priority.sym);\\0012evt_mbody += find_msg(63, 26, assignee.combo_name);\\0012evt_mbody += find_msg(63, 27, affected_contact.combo_name);\\0012evt_mbody += find_msg(63, 11, description);\\0012\\0012int evt_level;\\0012evt_level = 2;\\0012int trans_pt;\\0012trans_pt = 29; \\0012string contact_persid;\\0012\\0012if (!is_null(affected_contact.organization) && !is_null(affected_contact.organization.contact))\\0012{\\0012contact_persid = format(\"cnt:%s\", (string)affected_contact.organization.contact);\\0012   send(top_object(), \"call_attr\", \"cnt\", \"notify_list\",\\0012        contact_persid, evt_level, evt_mtitle, evt_mbody, \"\", trans_pt, persistent_id, 0, 0);\\0012}\\0012if (msg_error()) {\\0012   logf(ERROR, format(\"macro event error '%s'\", msg[0]));\\0012}\\0012",
        "12011" ,"" ,"" ,"0" ,"" ,"" ,"chg" ,"macro:12011",
        "Notify Affected End User's Org" ,"" ,"ACT" ,"" ,"" ,"" ,"" ,"" ,"" }

    ... and that is the format that is required to import a macro.

    Regards,

    James



  • 14.  Re: Store Mail address in incident field in case of maileater
    Best Answer

     
    Posted 07-03-2018 04:38 AM

    You can also make the action macro less cumbersome by moving most of the functionality to a Spel macro.  Put this code in 'zcrEmailFromInit.spl' in site\mods\majic.  In a SPL file the quotes do not have to be escaped and the code can be formatted as normal:

    string cr::zEmailFromINIT(...) // Arg: CR Persistent_id
    {
        //
        // Get the INIT alg for a CR with description beginning "created via email interface by ",
        //  extract the alg description and extract the text from the label 'FROM_EMAIL=' to the end of the description.
        //

        string method;
        method="cr::zEmailFromINIT";
        // Find an INIT alg for this CR, with description starting with 'created via email interface by '

        string inPersid;
        inPersid = argv[0];

        string theDesc;
        object alg_list;
        object theAlg;
        int    alg_count;
        int    alg_index;
        int    idxFrom;
        string sFrom;
        string theFROMlabel;

        send_wait(0, top_object(), "call_attr", "alg", "sync_fetch", "RLIST_DYNAMIC",
          format("call_req_id='%s' and type='INIT' and description like 'created via email interface by %'", inPersid),
          1, 0);

        if (msg_error())
        {
            logf(ERROR, "%s: Error on sync_fetch for INIT ALG for %s", method, inPersid);
            return "";
        }

        alg_list = msg[0];
        alg_count = msg[1];

        if (alg_count <= 0)
        {
            logf(SIGNIFICANT, "%s: no INIT alg for email interface for %s", method, inPersid);
            return "";
        }

        // Get the first (and should be the only) INIT with an email description
        alg_index = 0;
        send_wait(0, alg_list, "dob_by_index", "DEFAULT", alg_index, alg_index);

        if (msg_error())
        {
            logf(ERROR, "%s: Error on dob_by_index for INIT ALG for %s, index %d: %s", method, inPersid, alg_index, msg[0]);
            return "";
        }

        theAlg = msg[0];
        theDesc = theAlg.description;

        theFROMlabel = "FROM_EMAIL=";
        idxFrom = sindex(theDesc, theFROMlabel);
        if (idxFrom >= 0)
        {
            sFrom = substr(theDesc, idxFrom + strlen(theFROMlabel));
            return sFrom;
        }
        else
        {
            logf(ERROR, "%s: FROM_EMAIL not found in INIT ALG for %s", method, inPersid);
            return "";
        }
    }

    Then the action macro just has to call the spel function, which makes it easier to edit and manage:

    TABLE Spell_Macro
        del description fragment id last_mod_by last_mod_dt lock_object msg_html
        msg_tmpl_info ob_type persid sym tenant type usr_integer1 usr_integer2 usr_integer3
        usr_string2 usr_string3 usr_string4
        { "0" ,"Capture email from INIT alg as zFrom",
        "// Requires the CR to be locked.\\0012string method;\\0012method=\"zcrSetzFromFromINITAlg\";\\0012//\\0012// Call cr::zEmailFromINIT to get the From email address (if any) from the INIT log record.\\0012//\\0012string sFrom;\\0012sFrom = cr::zEmailFromINIT(this.persistent_id);\\0012\\0012if (strlen(sFrom) > 0)\\0012{\\0012    this.zFrom = sFrom;    \\0012}\\0012else\\0012{\\0012    logf(ERROR, \"%s: FROM_EMAIL not found in INIT ALG for %s\", method, this.persistent_id);\\0012}\\0012return;",
        "400005" ,"" ,"" ,"1" ,"" ,"" ,"cr" ,"macro:400005",
        "zcrSetzFromFromINITAlg" ,"" ,"ACT" ,"" ,"" ,"" ,"" ,"" ,"" }

    The only downside of this approach is that you need to restart the SDM service to get the spel server to load the new function from site\mods\majic.



  • 15.  Re: Store Mail address in incident field in case of maileater

    Posted 07-03-2018 12:27 PM

    Hello James,

     

    Post adding spl file, getting error against file as follows:

    07/03 17:55:15.37 RH-CA-VM-03 spelsrvr 4412 ERROR script.y 3882 E:/PROGRA~2/CA/SERVIC~1/site/mods/majic/zEmailFromINIT.spl at (3) syntax error

    07/03 17:55:15.37 RH-CA-VM-03 spelsrvr 4412 ERROR intpnoex.c 640 Error 1 processing Spell file E:/PROGRA~2/CA/SERVIC~1/site/mods/majic/zEmailFromINIT.spl

    07/03 17:55:15.38 RH-CA-VM-03 spelsrvr 4412 FATAL spel_srvr.c 306 Could not parse files in E:/PROGRA~2/CA/SERVIC~1/site/mods/majic

    Spl file is as followed:

    string cr::zEmailFromINIT(...) // Arg: CR Persistent_id

    {

        //

        // Get the INIT alg for a CR with description beginning "created via email interface by ",

        //  extract the alg description and extract the text from the label 'FROM_EMAIL=' to the end of the description.

        //

      

        string method;

        method="cr::zEmailFromINIT";

        // Find an INIT alg for this CR, with description starting with 'created via email interface by '

      

        string inPersid;

        inPersid = argv[0];

      

        string theDesc;

        object alg_list;

        object theAlg;

        int    alg_count;

        int    alg_index;

        int    idxFrom;

        string sFrom;

        string theFROMlabel;

      

        send_wait(0, top_object(), "call_attr", "alg", "sync_fetch", "RLIST_DYNAMIC",

          format("call_req_id='%s' and type='INIT' and description like 'created via email interface by %'", inPersid),

          1, 0);

      

        if (msg_error())

        {

            logf(ERROR, "%s: Error on sync_fetch for INIT ALG for %s", method, inPersid);

            return "";

        }

      

        alg_list = msg[0];

        alg_count = msg[1];

      

        if (alg_count <= 0)

        {

            logf(SIGNIFICANT, "%s: no INIT alg for email interface for %s", method, inPersid);

            return "";

        }

      

        // Get the first (and should be the only) INIT with an email description

        alg_index = 0;

        send_wait(0, alg_list, "dob_by_index", "DEFAULT", alg_index, alg_index);

      

        if (msg_error())

        {

            logf(ERROR, "%s: Error on dob_by_index for INIT ALG for %s, index %d: %s", method, inPersid, alg_index, msg[0]);

            return "";

        }

      

        theAlg = msg[0];

        theDesc = theAlg.description;

      

        theFROMlabel = "FROM_EMAIL=";

        idxFrom = sindex(theDesc, theFROMlabel);

        if (idxFrom >= 0)

        {

            sFrom = substr(theDesc, idxFrom + strlen(theFROMlabel));

            return sFrom;

        }

        else

        {

            logf(ERROR, "%s: FROM_EMAIL not found in INIT ALG for %s", method, inPersid);

            return "";

        }

    }



  • 16.  Re: Store Mail address in incident field in case of maileater

     
    Posted 07-03-2018 09:37 PM

    Please email me directly at james.campbell@ca.com and I'll send the spl as plain text, which loads and runs without error on my sandbox.  Possibly there is a non-printing or other invalid character in the text copied from the thread.

    Regards,

    James



  • 17.  Re: Store Mail address in incident field in case of maileater

    Posted 07-03-2018 11:23 PM

    Hello James

     

    Please share spl in abinash.sahoo@sterlite.com.



  • 18.  Re: Store Mail address in incident field in case of maileater

    Posted 07-03-2018 11:40 PM

    Thanks a lot James for all the support.



  • 19.  Re: Store Mail address in incident field in case of maileater

     
    Posted 07-04-2018 12:17 AM

    You are very welcome.