How to specify the ToDoList in the "To" field of the Email template?

I am trying to use the Email Manager library (from ProcessMapping.com.au) on my v9.2 BPM platform.  I have managed to get it all plumbed in and working ok (with some minor adjustments here and there) but I now want to create an email template that sends to all those who are on the ToDoList of the stage that is invoking the email template.  I can't find any documentation (well it is a freebie!) and as yet have not managed to find the correct sytax for specifying the ToDoList in the To field.  Is anyone out there using this library and if so could you give me a firendly pointer or two on this?  I am using the QueEmailTemplate activity from that library amd passing in the relvant template name and the value "Current" for the Process 'current' Object parameter - is this correct or should I be passing in something more specific (the parameter is expecting a Map type object)? Any help would be greatly appreciated.

Tagged:

Comments

  • I have tried simply putting the value "ToDoList" in the To field but this does not yield any recipients at run time. However, if I put the name of another valid role in the To field it works fine. Could it be that the ToDoList is not evaluated at the time I am invoking the email template? If so how can I either force evaluation prior to my email invocation or where else could I invoke it from that would have the ToDoList evaluated (I am currently invoking from the When Stage Started event)?

  • Have you tried the

    GetToDoList("FOLDERID") such as GetToDoList(ProcessContext.FolderId)
    

    built in function?  That returns everybody currently assigned to the To Do list for the indicated Folder ID.

    I haven't looked at the library in a while, but if it takes a list argument (which I believe it does) I'd think passing this in would work.  If the library doesn't take a list type, then convert it to another type while passing in the value list.

  • Many thanks for the suggestion. I have just confirmed that it seems to be a timing issue. If I call the GetToDoList function at the 'When Stage Started' event it returns nothing. However, if I call it at the 'When Stage Completed' event I get the expected results. So now I want toknow if a refresh of the ToDoLists can be forced programatically and if so how?

  • Programatically - I don't think so, but others may know better.  There is a setting for a poll interval to regenerate the list, but that may not help you in this case.

     

    I've not tried it in a stage, but it seems to work properly when in actions -- at least thus far.  (Though I admit I don't use that role / function very often.)

  • Here is a server script that gets promoted to the expression builder.  You pass in the parameter 'Current' and it will return a semi colon separted list of email addresses for users who have the folder on their to do list (so you should only call it "When Stage starts":

     

    [Promote(PromotionTargets.ExpressionBuilder)]

    [Category(

    "Email Extensions")]

    [Alias(

    "Generate To Do List E-Mail Addresses")]

    public

    staticstring GenerateTodoListEmailAddresses(object processInstance)

    {    

         

    string retval = string.Empty;

         

    string nextStage = new ProcessContext().StageName;

          ArrayList emailList =

    new ArrayList();

          MethodInfo method = processInstance.GetType().GetMethod(

    "GetStage");

         

    object stage = method.Invoke( processInstance, newobject[]{nextStage});

         

    if( stage != null )

          {

                PropertyInfo stageInfo = stage.GetType().GetProperty(

    "ToDoList" );

               

    object todoList = stageInfo.GetValue(stage,null);

               

    foreach(string todo in (IEnumerable)todoList )

                {

                     

    if( !string.IsNullOrEmpty( Mstm.GetEmailAddress( todo ).ToString() ) )

                      {

                            emailList.Add( Mstm.GetEmailAddress( todo ).ToString() );

                      }

                }

          }

         

         

    if( emailList.Count > 0 )

          {

                retval =

    string.Join(";",(string[])emailList.ToArray(typeof(string)));

          }

         

         

    return retval;

    }

  • As this is posted on the Metastorm forum by a Metastorm employee and we have not been informed otherwise, can we assume that this is all fully supported functionality, and we will be able call on Metastorm support should any of it break in the future for any reason?

  • Many thanks to all who posted responses on this thread.

    In the end I created a very simple (perhaps too simple?) liitle function:

     

    public class UsersFromADGroup

    {

       [Promote(PromotionTargets.ExpressionBuilder)]

       [Category("UserCategory")]

      

       publicstatic List ListUsersFromADGroup(List lNames)

           {

          string sNames = string.Join("','", lNames.ToArray());

                    return Core.Mstm.SelectSql(null,"SELECT eUserName FROM eUser
                                           WHERE eDistinguishedName in
                                        ('"+sNames+"')").List;

           }

    }

     

    I called this funtion in the Custom data List field of the Queue Email Template With Custom Data eventmodule (provided in the Toolbox by the Email Manage library from ProcessMapping) as follows:

       "ToDoList "+GetToDoList(ProcessContext.FolderId)

     

    Then in To field of the email template itselIf I put  

     

    I also had to modified the Replace Custom Tags script of the Email Manager library slightly (which substitues the values in place of the Custom  place holder) in order to put comma separators between each recipient user name.

     

    The result appears to be working ok so far, although I suspect I will be replacing ProcessMapping's  Email manager library with a more sophisitcated and developed offering soon.

     

    Thanks all  

  • Appears part of my previous posteng dropped off, so heres the missing pieces:

    ...

    In the To field of Email template iteself I put the following: [Custom.ToDoList]

  • Oh, and one more thing I should mention respecting the timing issue...

    I found that I needed to allow time for the ToDoList to be evaluated by the Alerts processor before I attempted to read it for my email template, so I just used a Timed action with a 1 minute delay set after the stage is started before triggering the email manager's template. Simples.

  • Or, somewhat more succinctly:

    GetEmailAddresses( Current.GetStage( ProcessContext.StageName ).ToDoList.ToArray() );

     


    Robin Gibb wrote:

    Here is a server script that gets promoted to the expression builder.  You pass in the parameter 'Current' and it will return a semi colon separted list of email addresses for users who have the folder on their to do list (so you should only call it "When Stage starts":

     

    [Promote(PromotionTargets.ExpressionBuilder)]

    [Category(

    "Email Extensions")]

    [Alias(

    "Generate To Do List E-Mail Addresses")]

    public

    staticstring GenerateTodoListEmailAddresses(object processInstance)

    {    

         

    string retval = string.Empty;

         

    string nextStage = new ProcessContext().StageName;

          ArrayList emailList =

    new ArrayList();

          MethodInfo method = processInstance.GetType().GetMethod(

    "GetStage");

         

    object stage = method.Invoke( processInstance, newobject[]{nextStage});

         

    if( stage != null )

          {

                PropertyInfo stageInfo = stage.GetType().GetProperty(

    "ToDoList" );

               

    object todoList = stageInfo.GetValue(stage,null);

               

    foreach(string todo in (IEnumerable)todoList )

                {

                     

    if( !string.IsNullOrEmpty( Mstm.GetEmailAddress( todo ).ToString() ) )

                      {

                            emailList.Add( Mstm.GetEmailAddress( todo ).ToString() );

                      }

                }

          }

         

         

    if( emailList.Count > 0 )

          {

                retval =

    string.Join(";",(string[])emailList.ToArray(typeof(string)));

          }

         

         

    return retval;

    }