Adding Activities and History to a Custom Main Entity in the Saleslogix Web Client (Part 4)

I am near the end of a series of posts providing some easy to follow steps that will help a developer add the ability to associate Activity and History records for a custom main entity within the SalesLogix Web Client.  Read the previous three posts to catch up on where we are at. Part 1 Part 2, and  Part 3

Since the previous two posts went into great detail, today we are going to mostly focus on the code and where it goes.  You still need the definitions we used in your code in parts 2 and 3.  There are three areas we will modify today in the SalesLogix Application Architect(AA).  Please find and open the following:

CompleteActivity.ascx  (This holds the properties for the Complete Activity Page)
CompleteActivity.ascx.resx (This holds the definition for the labels the page above)
CompleteActivity.ascx.cs (This holds the code supporting the page)

Once again you find these files in the AA under the Project Explorer Tab following same process as detailed in parts 2 and 3.  

Let’s get started with the CompleteActivity.ascx. To add our code navigate to the end of line 205, hit the enter button, and paste in the following lines:

<%–Start My Code –%>
<%–End My Code –%>

These should be lines 206 and 207. Go to the end of line 206 and hit the enter key again and then paste the following on empty line 207:

       <td colspan=”2″> 
                    <span class=”twocollbl”><asp:Label ID=”FieldName_lz” AssociatedControlID=”FieldName” runat=”server” Text=”<%$ resources: FieldName_lz.Text %>”></asp:Label></span>
                    <span class=”twocoltextcontrol”>
                            <SalesLogix:LookupControl Width=”95%” runat=”server” ID=”FieldName” AutoPostBack=”true” AllowClearingResult=”true” LookupBindingMode=”string” ReturnPrimaryKey=”true” LookupEntityName=”EntityName” LookupEntityTypeName=”Sage.Entity.Interfaces.IEntityName, Sage.Entity.Interfaces, Version=, Culture=neutral, PublicKeyToken=null”  >
                            <SalesLogix:LookupProperty PropertyHeader=”<%$ resources: Lookup_Field1.PropertyHeader %>” PropertyName=”Field1” PropertyFormat=”None”  UseAsResult=”True”></SalesLogix:LookupProperty>
                            <SalesLogix:LookupProperty PropertyHeader=”<%$ resources: Lookup_Field2.PropertyHeader %>” PropertyName=”Field2” PropertyFormat=”None”  UseAsResult=”True”></SalesLogix:LookupProperty>
                            <SalesLogix:LookupProperty PropertyHeader=”<%$ resources: Lookup_Field3.PropertyHeader %>” PropertyName=”Field3” PropertyFormat=”None”  UseAsResult=”True”></SalesLogix:LookupProperty>

Add your definitions using the lists we developed in Part 2.  

The modifications to the ScheduleCompleteActivity.ascx.resx field are pretty much as we did yesterday.  Here we want to navigate near to the very end of the file, on line 326, hit enter and paste in the following lines:

 <data name=”FieldName_lz.Text” xml:space=”preserve”>
 <data name=”Lookup_Field1.PropertyHeader” xml:space=”preserve”>
 <data name=”Lookup_Field2.PropertyHeader” xml:space=”preserve”>
 <data name=”Lookup_Field3.PropertyHeader” xml:space=”preserve”>

For the CompleteActivity.ascx.cs file there are 6 events we will modify.  Remember to take your time.  The first event we will work on is labeled OnFormBound, just before the closing bracket for the event add the following code:

        Sage.Entity.Interfaces.IActivity act = this.BindingSource.Current as Sage.Entity.Interfaces.IActivity; //Mine
        if (act.FieldName != null) //Mine
            FieldName.LookupResultValue = act.FieldName.ToString(); //Mine

To make sure we are all on the same page here, “FieldName” is the name of the field in the Activity Entity that represents our custom main entity.  In my example FieldName = FXProjectId


For the Page_PreRender event, look for a line that looks similar to this:

TicketId.InitializeLookup = (TicketId.SeedValue.Length == 12);

Right under this line add the following line of code and then add your definition for FieldName to the code.

FieldName.InitializeLookup = (FieldName.SeedValue.Length == 12); //Mine


For the LeadId_LookupResultValueChanged event, look for a line that looks similar to this:

Activity.AccountId = null;

Right under this line add the following line of code and then add your definition for FieldName to the code.

Activity.FieldName = null;//Mine


For the AccountId_ChangeAction event, look for a line that looks similar to this:

Activity.LeadId = null;

Right under this line add the following line of code and then add your definition for FieldName to the code.

Activity.FieldName = null;//Mine


For the SetTacoDefaults event, look for a group of code that looks similar to this:

 if (GetParam(“tid”) != null)
     Activity.TicketId = GetParam(“tid”)


Right under this code add the following.  In Part 3 (UPDATE WITH LINK) of this series you established an “alias2″, make sure to use that same definition for alias2 in this code.

if (GetParam(“alias2“) != null)//Mine


Activity.FieldName = GetParam(“alias2“);//Mine


Still in the SetTacoDefaults event, look for the case statements not to far below the code you just set in place.    You should find a case statement for ITicket.  Add the following group of code on the next line after the break of the ITicket case statement.

 case “IEntityName“://Mine
      found = true;
      IEntityName alias = EntityFactory.GetById<IEntityName>(hist.EntityId.ToString());
      Activity.FieldName = alias.Id.ToString();
      Activity.AccountId = alias.Account.Id.ToString();
      Activity.AccountName = alias.Account.AccountName;

This area is setting some defaults based on where you are launching the CompleteActivity page from.  Think about if you were launching from your custom main entity, what field can you pre-populate.  In the example I am providing the assumption there is a relationship to the Account entity named “Account”.   You need another definition for alias and this can be anything,  as I did in the last post I am going to use a shorten version of my definition for EntityName so for me alias = fxproj.

The final event today is one labeled OnAddEntityBindings(),  at the end of this event add these two line of code:

 bs.Bindings.Add(new WebEntityBinding(“FieldName“, FieldName, “LookupResultValue”));//Mine
 bs.Bindings.Add(new WebEntityBinding(“AccountId”, FieldName, “SeedValue”));//Mine

Remember –  here again, if there is not a relationship to the account from your custom main entity name Account, then either delete or modify the second line as needed.

To test, save all files, build your web platform, then redeploy your site.  When the website comes up go to any open activity in one of the Activity List views, select “Complete” from the list.  When the Complete Activity page opens you should see your field, below you will see mine.

That’s enough for today, we will finish out our seires with process for seeing the Activites and hitory Tabs on your custom main entity.



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) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!