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

My goal within this series of post is to provide 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 two posts to catch up on where we are at. Part 1 Part 2.


As promised in the last post we are going to get right at it today.  The process is going to be very similar to what we did in Part 2.  As a reminder, you will need the definitions we used in our code in part 2.  There are three areas we will modify today in the SalesLogix Application Architect(AA).


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


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:


ScheduleCompleteActivity.ascx       
ScheduleCompleteActivity.ascx.cs


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


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


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


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



<%–Start My Code –%>
 </tr>
 <tr>
  <td>
            <span class=”lbl”><asp:Label ID=”FieldName_lz” Text=”<%$ resources: FieldName_lz.Text %>”  AssociatedControlID=”FXProjectId” runat=”server”></asp:Label></span>
        </td>
  <td>
   <span class=”textcontrol”>
    <SalesLogix:LookupControl runat=”server” ID= “FXProjectId” AutoPostBack=”true” AllowClearingResult=”true” LookupEntityName=”EntityName” OverrideSeedOnSearch=”true” SeedProperty=”Account.Id
      LookupEntityTypeName=”Sage.Entity.Interfaces.IEntityName, Sage.Entity.Interfaces, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null” >
    <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>
   </span>        
  </td>
<%–End My Code –%>


The code above is very similar to the code we added in part 2 but there are some differences.  Once the code is in place use the definitions from part 2 fill in FieldName, EntityName, and the Fields (1, 2, and 3). 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.  FYI, there is an assumption within this code that your Main Custom Entity has a relationship to the Account layer labeled “Account”, if this is not true then you do not include the SeedProperty=”Account.Id” in your code.  When you have completed this area make sure you save your work.


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”>
 <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>


Using your definitions fill in FieldName, LookupLabel, Fields (1, 2, and 3) and FieldLabels (for 1, 2, and 3). 


When ready save your work and open the ScheduleCompleteActivity.ascx.cs file.  If you remember yesterday here we are updating already established events to work with our custom entity lookup.  You can search for these events with in the file using the drop down field in the upper right hand corner.  Simply find and select the event and AA will take you to the correct spot in the code. 


First lets search for the “ResetForm” event.   Look for a line that looks like this:


Ticket.LookupResultValue = null;


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


FieldName.LookupResultValue = null;//Mine


 


Next lets search for the “SetSeedValues” event.   Look for a line that looks like this:


LeadId.InitializeLookup = false;


Right under this line add the following line of code and then add your definition for FieldName to the code.  The second line is only used if you have a relationship from your Main Entity to the Account Entity and that relationship is name Account.  If this does not exist then you may not want to use the second line.


FieldName.InitializeLookup = true;//mine
FieldName.SeedValue = seedValue;//mine


 


Now this next section gets a little hairy so take your time.  Search for the btnContinue_Click event.  Look for a line that looks like this:


string leadId = “”;


This line is declaring a variable.  Directly below this line add the following code:


string variable = “”; //mine


The definition for variable can be anything. I am going to use a shorten version of the definition for my FieldName and I will set the text to all lowercase,  so for me variable = fxprojid.


Staying in the same event you will a set of code that looks like this:


if (LeadId.LookupResultValue != null)
  {
    Lead lead = LeadId.LookupResultValue as Lead;
    if (lead != null)
  {
leadId = lead.Id;


We need to add similar code right underneath this set, should look this:


if (FieldName.LookupResultValue != null) //Mine
  {
   EntityName alias = FieldName.LookupResultValue as EntityName;//Mine
   if (alias != null)//cfx
     {
       variable = alias.Id;//cfx
     }
  }


Again, add your definitions for EntityName, FieldName, and then use the variable we defined above.  Just like for variable you need another definition for alias, this can be anything so I am going to use a shorten version of my definition for EntityName so for me alias = fxproj.


Still staying in the same event look for a line that looks like this.


Dictionary<string, string> args = new Dictionary<string, string>();


In this group of code we need to add another line similar to this:


args.Add(“alias2“, variable);//Mine


You can see the variable we defined is used again in this bit of code along with another alias.  For alias2 we will follow SalesLogix policy and use the first initial of our EntityName in lowercase – example alias2 = pid


That should do it for the Schedule Complete Activity set of files.  To test, save all files, build your web platform, then redeploy your site.  When the website comes up go to the Schedule Menu Item, select “Complete an Activity” from the list. 


Your view should come up with your field right below the Ticket Look up.   Here is mine:



Next up on our list is CompleteActivity.ascx.resx, CompleteActivity.ascx, and CompleteActivity.ascx.cs files. 


Take care until then!


Geo

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!