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

Yesterday I started a series of post that will talk the reader through giving the ability to schedule activities and review history records for a custom main entity. Today we will continue on with the first set of modifications.  Before we get in too deep we need to define some elements to use in our code.  These definitions will be used over and over again as we move through this process so keep a separate list handy for easy references.  One thing to remember while determining these definitions is the use of proper case in C# code.  If you put a capital letter where a lowercase should be, C# will throw an error.  


In the last post I asked you to come up with the fields from your entity that will be used in your Activity lookup.  I will have three fields in my lookup, from the FXProject Entity I will have “Name” and “Status”, and through a relationship to the User Entity called ProjectManager I will also have the UserName field.


Field1 = Name
Field2 = Status
Field3 = ProjectManager.UserName


Now those are the names of the fields as they are created in the entities.  These may or may not be the names of the columns for your lookup.  So Lets define what the columns names are:


Field1Label = Project Name
Field2Label = Status 
Field3Label = Project Manager


When I look at the lookup on the Activity Detail page I want the field to have a label. For me, my lookup is for a project so in my case LookupLabel = Project:


Two other things to think about ahead of time are EntityName and FieldName.


EntityName is easy, look at the tree control and find the exact spelling using proper case, for my example I will use EntityName = FXProject.


For the FieldName lets use the name of the field we added to the Activity and History tables (In Part 1) as the name for the lookup field. This is consistent with the Account and Contact lookup already built on the pages we are going to modify.  The name I used was “FXProjectId”, so for todays code FieldName = FXProjectId


Lets add some code.


There are three areas we will modify today in the SalesLogix Application Architect(AA).


ActivityDetails.ascx  (This holds the properties for the Activity Details Page)
ActivityDetails.ascx.resx (This holds the definition for the labels)
ActivityDetails.ascx.cs (This holds the code so the form reacts as expected)


You can find these files in the AA under the Project Explorer Tab.  In the tree control look for and open the Portal Manager, then Sage SalesLogix, then Support Files, then Smart Parts, and then Activity.


Right click and select “Open” on the following files:


ActivityDetails.ascx       
ActivityDetails.ascx.cs


Then open another folder just above Activity in the tree labeled “App_LocalResources”. Right click and select open a file named “ActivityDetails.ascx.resx”.


The first file we will work with is ActivityDetails.ascx.  This file holds the code for the controls that make up the page that displays when you edit an activity. To add our code navigate to the end of line 247, hit the enter button, and add the following lines:


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


I do this to help my find my code quicker especially when I am combing the use of Visual Studio with AA.  These should be lines 248 and 249. Now put a line between these two, this is where you can paste in the following code that builds your custom entity lookup:



    </tr>
    <tr class=”contact-row”>
         <td>
            <div class=”lbl alignleft”><asp:Label ID=”FieldName_lz” AssociatedControlID=”FieldName” runat=”server” Text=”<%$ resources: FieldName_lz.Text %>”></asp:Label></div>
            <div class=”textcontrol”>
                <SalesLogix:LookupControl runat=”server” ID= “FieldName” AutoPostBack=”true” AllowClearingResult=”true” OverrideSeedOnSearch=”true” LookupBindingMode=”string” ReturnPrimaryKey=”true” LookupEntityName=”EntityName” LookupEntityTypeName=”Sage.Entity.Interfaces.IEntityName, Sage.Entity.Interfaces, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null” SeedProperty=”Account.Id”>
                <LookupProperties>
                    <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>
                </LookupProperties>
                <LookupPreFilters>
                </LookupPreFilters>
                </SalesLogix:LookupControl>
            </div>        
        </td>


Read through the code and find and replace the FieldName, EntityName, and Fields (1, 2, and 3) as we defined above. I tried to bold all of the values that need to be changed. You see with EntityName some of the code has an “I” before the EntityName, ensure you leave this “I” in place.  When you have completed this area make sure you save your work.


With that code in place move to the ActivityDetails.ascx.resx file.  This is where the field labels are defined. Here we want to navigate to the very bottom the file on line 263, hit enter and add the following lines:


 <data name=”FieldName_lz.Text” xml:space=”preserve”>
 <value>LookupLabel</value>
 </data>
 <data name=”Lookup_Field1.PropertyHeader” xml:space=”preserve”>
 <value>Field1Label</value>
 </data>
 <data name=”Lookup_Field2.PropertyHeader” xml:space=”preserve”>
  <value>Field2Label</value>
 </data>
 <data name=”Lookup_Field3.PropertyHeader” xml:space=”preserve”>
  <value>Field3Label</value>
 </data>


Reference your labeling defined above for the FieldName, LookupLabel, Fields (1, 2, and 3) and FieldLabels (for 1, 2, and 3) and insert in the code.


Next we will move to the ActivityDetails.ascx.cs file.  This holds code that defines how the page and all of it’s properties react when loading or when changes occur. This can be pretty complicated for the unexperienced developer so take your time.


The first thing I did was to close all of the tree control items so my view looked like this. 



If you look up in the upper right hand corner of the screen shot you will see a field with a the value of “Page_PreRender”.  This field will help you find the code we are going to modify.  You simply look for the values I provide you and add code where indicated.


The first item I am going to search for is the Page_PreRender event.  You might have to click on the plus sign to open to the code, when the code is visible look for a lint that looks like this:


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


Right under this line add the following line of code:


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


Add your definition for FieldName to the code and close up the tree.  Replace the word mine with your initials, again to help you find your code later if necessary.


 


Search for the “AccountId_LookupResultValueChanged” event.  Look for a line that looks like 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


 


Search for “LeadId_LookupResultValueChanged” event.  Look for a line that looks like 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


 


Search for the “SetTACODefaultsFromHistoryId” event.  Look for a line that looks like this:


Activity.LeadId = hist.LeadId;


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


Activity.FieldName = hist.FieldName; //Mine


 


Search for the “SetTACODefaultsFromEntityHistory” event.  Here there are several Case statements. We will add our code to the end of these existing Case statements.  FYI, this area assumes that your main entity has a relationship built to the Account Entity and the the relationship name is Account. IF this is not the case I would leave the AccountId line out.


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


Add your definition for EntityName and FieldName.


 


Search for the “OnAddEntityBindings” event.  Copy these lines any where within the brackets put in your definition for FieldName.  Here again is an assumption about a relationship to the Account.  If you do not have a relationship for the Account I would not use the second line.
     bs.Bindings.Add(new WebEntityBinding(“FieldName“, FieldName, “LookupResultValue”));//Mine
     bs.Bindings.Add(new WebEntityBinding(“AccountId”, FieldName, “SeedValue”));//Mine


 


With this last bit of code in place make sure you save your work.  Go ahead and build your platform and Deploy your Test environment to see if everything is working correctly.  The best place to test at this point is by editing an exisitng Activity.  Mine worked well, here is a screen shot.



I know this was a lot of information all at once, the next post should be a little less at once.  The next post will cover modifying the following custom smart parts:


ScheduleCompleteActivity.ascx.


ScheduleCompleteActivity.ascx.resx


ScheduleCompleteActivity.ascx.cs


Until then peace.


 

1 Comment

  1. How can we customize the Activity List Tab in Opportunity Detail in InforCRM 8.2.0.1 ? How can we customize column of Activity List Tab. Any help would be great!

    Reply

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!