Archive for the 'Deltek' Category

25
Nov
09

#32 Our Expense Notices

We send out simple email notices from information in Deltek’s database.

If you have the Enterprise Edition of SQL Server you can do this straight-up using Data Driven Subscriptions which is a really nice feature of SQL Reporting that allows you to use a query to determine who gets the report via email and what is in the report for each one sent. Here is a link to get you started: http://msdn.microsoft.com/en-us/library/ms169673.aspx

But since we do not have that license and option I am using code to to the two queries – (1) the target email address & (2) the report details – namely their expense report.

This is the extraction Stored Procedure:

Procedure [dbo].[BWSP_getExpenseReceipts]
as
Select      EM.email
,               EM.Employee
,               EX.EmployeeName
,               EX.Amount
,               EX.CheckNo
,               EX.CheckDate
,               EX.ReportName
,               EX.ReportDate
from EM
Join exChecks EX on ( EM.Employee = EX.Employee )

On our intranet we have a grid that displays the pending check receipt data & a simple process button to approve. This page is secure to accounting personnel.

The process uses SMTP and data from the Stored Procedure above to form an individual email for each involved employee.

 private void sendNotifications()
    {

        string sTitle = "Expense Check Notification";
        string sMsg = "";
        string sSourceEmail = @"***@***";
        DataSet ds = DeltekUtilities.getPendingExpenseNotifications(); // ADO call to get data using the SP above
        DataTableReader  dr = ds.CreateDataReader();
        int ii = 0;
        while (dr.Read())
        {
            ii++;
            sMsg = "===================================================================================" + "\n";
            sMsg += "                    Expense Check Notification   " + "\n";
            sMsg += "===================================================================================" + "\n\n";
            //sMsg += "               Email: " + dr["email"].ToString() + "\n";
            sMsg += "            Employee: " + dr["EmployeeName"].ToString() + "\n";
            sMsg += "      Deposit Amount: " + String.Format("{0:c}", Double.Parse(dr["Amount"].ToString())) + "\n";
            sMsg += "        Deposit Date: " + String.Format("{0:d}", dr["CheckDate"]) + "\n";
            sMsg += "         Description: " + dr["ReportName"].ToString() + "\n";
            sMsg += "---------------------------------------------------------------------------------";

            try
            {
                Utilities.sendEmail(sSourceEmail, dr["email"].ToString().Trim(), string.Empty, sTitle, sMsg, false);
            }
            catch (Exception ex)
            {
                lblMessage.Text += "<br> error sending: " +  dr["email"].ToString();
            }
        }
        if (dr != null)
        {
            dr.Close();
            dr.Dispose();
        }

        lblMessage.Text += "<br>" +  ii.ToString() + " Emails Sent";

    }

// Send Email Utility Call

public static bool sendEmail(string sSourceEmail, string sTargetEmailList, string sCCEmailList, string sMsgTitle, string sMsg,  bool isHTMLemail)
    {

        bool bReturn    = false;
        SmtpClient client = new SmtpClient();
        client.Host = "****";
        MailMessage mm = new MailMessage();
        try
        {
            mm.Sender       = new MailAddress(sSourceEmail);
            mm.From         = new MailAddress(sSourceEmail);
            mm.To.Add (new MailAddress(sTargetEmailList));
            if (sCCEmailList.Length > 0)
                mm.CC.Add (new MailAddress(sCCEmailList));
            mm.Subject      = sMsgTitle;
            mm.Body         = sMsg;
            mm.IsBodyHtml   = isHTMLemail;

            client.Send(mm);
            bReturn = true;
        }
        catch (Exception ex)
        {
            string sEmails = " Email List [" + sSourceEmail + " " + sTargetEmailList + " " + sCCEmailList + "] ";
            throw new IntranetException(ex.Message + sEmails,
                                              ex,
                                              SystemConstants.Intranet_ErrorMessage);

        }

        return bReturn;
    }
15
Jul
09

#29 PopUp under Deltek 6.x Smart Client

The issue is that by running a smart client an iframe or window open launches a browser window separate from the smart client which is a Windows client executable & not a browser app. Since that is unavoidable using a modal window with target self tag in the head works best. This method will however still leave the initial help window open in the smart client.

Add the Help Icon ? and replace the Help Text (directly via a control-V paste do not click on ellipse to launch editor) with:

<script>javascript:  window.showModalDialog("http://targetpage.aspx",'_parent', "dialogHeight: 200px;");</script>

In your target page (html or aspx) since this is a modal window this will ‘correct’ any postbacks from launching a new window.

<HTML>
                <HEAD>
                                <base target="_self" />
 ...

Put a button with a OnClick event to close this popup. The window.opener=’X';window.open(”,’_parent’,”);window.close(); will avoid the usual warning.

Credit Due on avoiding the window close warning: http://blogs.x2line.com/al/articles/350.aspx

					function CopyToClipboard()
					{
						document.frmVisible.txtJobNumber.focus();
						document.frmVisible.txtJobNumber.select();
						CopiedTxt = document.selection.createRange();
						CopiedTxt.execCommand("Copy");
						alert('Number has been copied. Use Control-V to paste into new project screen.');
						window.opener='X';window.open('','_parent','');window.close();
					}

cf . http://dmgorman.wordpress.com/2008/01/11/02-simple-popup-help-page/

26
Jun
09

#28 Deltek operator (agent) ID & email via Workflow

If you need to get the agent processing the workflow you can call the UDF GetVisionAuditUsername()

You can then wrap this UDF call in a SP to get something like an Email address from the EM table for email processing to the operator/agent which is something missing from Deltek’s WF options. Sending the person doing the operation (agent) an email has been missing in Deltek WF (you can send their manager an email but not the person doing the work). At least this is what we see in 5.1 and since 6.0 is same/same we probably have the same issue there – though I have not checked there. If anyone sees otherwise please post a comment. Thanks!


** Note: This will require the context provided by Deltek’s WF since the UDF uses ‘context_info’ from master.dbo.sysprocesses **

Create Procedure getAgentEmail()
AS
BEGIN
	Declare @Employee as varchar(20)

	Select @Employee = [dbo].[GetVisionAuditUsername]()

	Select EM.Email
        From EM
        Where EM.Employee = Substring(@Employee,1,3)
            -- substring if needed to get proper key

         -- It would be wise to parm these values in!
         EXEC msdb..sp_send_dbmail
            @profile_name='ProfileName'
           , @recipients= @Email
           , @subject='Test message'
           , @body='This is the body of the test message'

END

SQL 2008 Mail Setup
http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/