Another Issue Discovered in Infor CRM v8.1 Update 5- Sales Process Activity Dates Are Off

We had a client who discovered when clicking to create a timeless Activity from a Opportunity Sales Process step, the dates were one day off (behind).  In the Sales Process you can define the number of days in the future the Activity is to be created for.  So if you have an Activity that is to get created 4 days in the future, when you click to create the Activity from a Sales Process, the date would actually default to 3 days in the future.  I dug around and never really found the problem, but did find a fix to resolve the issue.

The creation of activities from the Sales Process tab is handled by a custom smart part in the OpportunitySalesProcess folder called SalesProcessService.aspx.  Inside the SalesProcessService.aspx.cs code file there is a method used called “ScheduleActivity” which returns a string of a new Activity ID.  Inside this method there is a call to get the SalesProcessAudit entity which is passed into the method as a parametrized array.

            ISalesProcessAudit spAudit = EntityFactory.GetById<ISalesProcessAudit>(spaId);
            if (spAudit != null)
            {
                IContact contact = EntityFactory.GetById<IContact>(contactId);
                IOpportunity opp = EntityFactory.GetById<IOpportunity>(opportunityId);
                IUser leader = EntityFactory.GetById<IUser>(leaderId);
                Activity activity = (Activity)spAudit.SalesProcess.ScheduleActivity(spaId, opp, leader, contact, true);
                activityId = (string) activity.Id;
            }  

The spAudit.SalesProcess.ScheduleActivity is a business rule in the SalesProcess entity.  Unfortunately, this is contained in the compiled Sage.Saleslogix.BusinessRules.dll and can’t be modified.  What it does is to parse out the details of the step that was clicked and then create an activity with these parameters.  The result of that is an Activity record.  Luckily with this Activity object being returned by the compiled method we can edit the results to correct the problem.  The only issue remaining is to do our own parsing of the step to get the step’s details. If we add our own code between these two lines:

                Activity activity = (Activity)spAudit.SalesProcess.ScheduleActivity(spaId, opp, leader, contact, true);
                activityId = (string) activity.Id;

We can do just that:

                //CFX Added to fix sales process being one day off               
                DateTime today = DateTime.Today;
                string xmlData = Encoding.UTF8.GetString(spAudit.Data);
                System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                document.LoadXml(xmlData);
                System.Xml.XmlNode node = document.DocumentElement.SelectSingleNode(“//Action/ActivityAction”);
                string innerText = node.SelectSingleNode(“Type”).InnerText;
                string daysOut = node.SelectSingleNode(“ScheduleDaysFromToday”).InnerText;
                string tml = node.SelectSingleNode(“Timeless”).InnerText;
                bool timeless = tml == “T”;
                int num = (daysOut != string.Empty) ? int.Parse(daysOut) : 0;

                if (timeless)
                {
                    activity.Notes = “Days: ” + num.ToString() + “Currently: ” + activity.StartDate.ToString(“MMddyyyy hh:mm:ss”) + ” | ” + today.Date.ToString(“MMddyyyy hh:mm:ss”) + ” | ” + today.AddDays(4).Date.AddSeconds(5).ToString(“MMddyyyy hh:mm:ss”);
                    activity.LongNotes = activity.Notes;
                    activity.StartDate = today.AddDays(num).Date.AddSeconds(5);
                    activity.Timeless = true;
                    activity.Save();
                }
                //End CFX Add to fix sales process being one day off

So the final code is:

    private string ScheduleActivity(string scheduleContext)
    {

        string activityId = string.Empty;
        try
        {
            string[] args = scheduleContext.Split(new Char[] { ‘,’ });
            string spaId = args[0];
            string contactId = args[1];
            string opportunityId = args[2];
            string leaderId = args[3];
            ISalesProcessAudit spAudit = EntityFactory.GetById<ISalesProcessAudit>(spaId);
            if (spAudit != null)
            {
                IContact contact = EntityFactory.GetById<IContact>(contactId);
                IOpportunity opp = EntityFactory.GetById<IOpportunity>(opportunityId);
                IUser leader = EntityFactory.GetById<IUser>(leaderId);
                Activity activity = (Activity)spAudit.SalesProcess.ScheduleActivity(spaId, opp, leader, contact, true);

                //CFX Added to fix sales process being one day off               
                DateTime today = DateTime.Today;
                string xmlData = Encoding.UTF8.GetString(spAudit.Data);
                System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                document.LoadXml(xmlData);
                System.Xml.XmlNode node = document.DocumentElement.SelectSingleNode(“//Action/ActivityAction”);
                string innerText = node.SelectSingleNode(“Type”).InnerText;
                string daysOut = node.SelectSingleNode(“ScheduleDaysFromToday”).InnerText;
                string tml = node.SelectSingleNode(“Timeless”).InnerText;
                bool timeless = tml == “T”;
                int num = (daysOut != string.Empty) ? int.Parse(daysOut) : 0;

                if (timeless)
                {
                    activity.Notes = “Days: ” + num.ToString() + “Currently: ” + activity.StartDate.ToString(“MMddyyyy hh:mm:ss”) + ” | ” + today.Date.ToString(“MMddyyyy hh:mm:ss”) + ” | ” + today.AddDays(4).Date.AddSeconds(5).ToString(“MMddyyyy hh:mm:ss”);
                    activity.LongNotes = activity.Notes;
                    activity.StartDate = today.AddDays(num).Date.AddSeconds(5);
                    activity.Timeless = true;
                    activity.Save();
                }
                //End CFX Add to fix sales process being one day off

                activityId = (string) activity.Id;
            }          
        }
        catch
        {
            activityId = string.Empty;
        }
        return activityId;
    }

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!