Process Mapping Logo

Process Mapping - Forums

Sharing 19 years of knowledge and experience

Metastorm BPM forums
Sign up Latest Topics

  Author   Comment  

Posts: 17
Reply with quote  #1 

I am just not sure how to approach this, perhaps someone on here can shed some light.

We have a process that is linked to a custom table, when this process is submitted on their verify step an email needs to be sent out to certain individuals with the detail of the relevant items in the custom table.

It needs to look something like this:

Please note that a discrepancy has been raised with the following details.
Source: W1
Target: B5

Reference: SR19123

1. Stock Code Quantity Type
2. Stock Code Quantity Type
3. Stock Code Quantity Type
4.Stock Code Quantity Type
5.Stock Code Quantity Type

Please ensure you attend to this as soon as possible.

*before I get nailed for email decorum please note this is but a sample  of intent.

Anybody know how I can add this kind of information when the email is being sent?

Thank you kindly.


Posts: 688
Reply with quote  #2 
When building your email body, if all of the values are in a BO associated with your process you can access them directly.  If there is no BO associated with the process, you can build your email body however you like until its contents are right, including doing a select against your custom table, looping if appropriate, to build and format your email message.  Then use the resulting email body in your email call.  I sometimes build the email in a code segment, or in a server script returning the email body depending on the complexity of the logic to build the email body.  (I've also done the send mail from a server script to if the To/CC is not simple as it sometimes isn't for us.)

Avatar / Picture

Posts: 5,507
Reply with quote  #3 
There is no 'simple' way. You would have to go through either the Business Object associated with the Form or Process (as BMellert says), or use a SelectSql() and parse the DataTable object.

Neither is easy, and we have used several approaches to get the data in a reusable function. Alas, all development on our MBPM libraries has been stopped now with the imminent demise of the product, so that part will not see the light of day.

In our Grid To HTML library we do something like this, using the DataTable object underlying the Grid:
#region Using Statement

using System;
using System.Data;
using System.Collections.Generic;
using Metastorm.Ide.Extensibility;
using Metastorm.Runtime.Core;
using Metastorm.Runtime.Types;
using System.ComponentModel;
using System.Collections;

#endregion Using Statement

namespace Metastorm.Runtime.Models.GridToHtml
public class ToHtml

#region Plain HTML

[Category("Grid to HTML")]
[Alias("Convert a Grid to plain HTML")]
[Description("takes a Grid and a title and returns a plain HTML table of the contents")]
public static string Plain
[Alias("The title of the Report")] [Description("The text you want on the header row of the report")] string ReportTitle,
[Alias("Grid Field")] [Description("Grid to get the column names from (Note: the NAMES, not the CAPTIONS are used)")] Metastorm.Runtime.Core.Forms.GridField Grid,
[Alias("Columns to ignore")] [Description("A comma delimited list of column numbers (zero based) that should not appear on the report")] string IgnoreColumnList
return BuildHtml( ReportTitle, Grid, IgnoreColumnList );

private static string BuildHtml
string ReportTitle,
Metastorm.Runtime.Core.Forms.GridField Grid,
string IgnoreColumnList
DataSet ds = (DataSet)Grid.DataValue;
DataTable dt = ds.Tables[0];
DataColumnCollection Columns = dt.Columns;
DataRowCollection Rows = dt.Rows;
IgnoreColumnList = "," + IgnoreColumnList + ",";

string TableStart = "<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" align=\"center\">";
string TableEnd = "</table>\r\n";
string TitleStart = "<caption><center><b>";
string TitleEnd = "</b></center></caption>\r\n";
string HeaderRowStart = "\t<tr>\r\n";
string HiddenRowStart = "\t<td style=\"display: none\">";
string HeaderRowEnd = "</tr>\r\n";
string HeaderCellStart = "\t\t<td><b>";
string HeaderCellEnd = "</b></td>\r\n";
string BodyRowStart = "\t<tr>\r\n";
string BodyRowEnd = "\t</tr>\r\n";
string BodyCellStart = "\t\t<td>";
string BodyCellEnd = "</td>\r\n";
string HTML = "";

HTML += TableStart + TitleStart + ReportTitle + TitleEnd;
HTML += HeaderRowStart;

List Headers;
foreach ( KeyValuePair<string,Metastorm.Runtime.Contracts.Forms.IColumnField> cf in Grid.ColumnList)
Headers = Headers.Append( cf.Key + "\r\n");

for ( int c = 0; c < Columns.Count; c++ )
if ( Mstm.FindSubstring(IgnoreColumnList, "," + c.ToString() + ",", false) == 0 )
HTML += HeaderCellStart + Mstm.ReplaceSubstrings( Headers[c], "_", " ", 0 ) + HeaderCellEnd;

for ( int r = 0; r < Rows.Count; r++ )
object[] Fields = Rows[r].ItemArray;
HTML += BodyRowStart;

for ( int f = 0; f < Fields.Length; f++ )
string FieldValue = Fields[f].ToString();

if ( FieldValue == "" || FieldValue == " " )
FieldValue = "&nbsp;";

if ( Mstm.FindSubstring(IgnoreColumnList, "," + f.ToString() + ",", false) == 0 )
HTML += BodyCellStart + FieldValue + BodyCellEnd;

HTML += BodyRowEnd;

HTML += TableEnd;

return HTML;

private static string formatDateTime
Metastorm.Runtime.Types.DateTime value,
Text format
return Mstm.FormatDateTime( value, format );

private static string formatCurrency
Decimal value
return string.Format("{0:C}", value);

#endregion Plain HTML

Post an example, and we will have a much better idea what the problem is. In about 90% of posts, the problem is one of communication. Examples bridge that gap.
Previous Topic | Next Topic

Quick Navigation:

Create your own forum with Website Toolbox!