Most of the time, it is a simple process to add or subtract fields from views in SalesLogix, but on occasion, it is necessary to perform those changes by modifying custom smartparts rather than making changes directly to a view. A good example of this in the Insert Contact/Account screen in the web client.
If you’re not familiar with ASP or C#, this can be a little intimidating, but hopefully this post will show the areas you need to modify when making changes to the custom smart part.
First of all, you need to find the custom smartpart. The easiest way to do this is to look at the Project Explorer in Application Architect. Expand the Portal manager, Sage SalesLogix, and Pages. Scroll down to the Insert Contact/Account page and double-click on it. This will open the page, and show all the smart parts used.
We’re interested in the InsertContact custom smart part, so highlight that and click the Edit button.
As you can see, this is all code. If you’ve worked with ASP before, this should be pretty easy to navigate. If not, you’ll have to do some looking around to find what it is you want to change. Say for example, you wanted to remove the standard “Business Description” field from this form. You should find ASP code referring to the the control on the form. You can then comment out or remove that code entirely.
Here you can see the code defining the Business Description field along with the code defining the Account Fax field. The placement of these fields is accomplished by using the standard <td> (cell) and <tr> (row) tags that are used in HTML. You’ll want to keep these tags in mind when removing fields, otherwise you might mess up your layout of the screen. For removing business Description, you’d want to remove everything including the <td> tags, but leave the closing </tr> tag in place.
After removing the control, you’ll want to run a search of the code to remove any reference to the “txtAccountBusinessDescription” control. Otherwise errors could be thrown when trying to reference a control that no longer exists.
For adding a new control, there are a couple other code items you will need to have in place to control things like control behavior, data bindings, etc… For this example, we’re going to replace the Business Description field we just removed with the Division field in the Account Table.
The first step you’ll want to take is to add the binding code for the new field. If you scroll down a ways, you’ll find the code change from ASP to C#. (Look for the line that reads “<script runat=”server” type=”text/C#”>” Everything below this line is the C# code.
Find the function named IsAccountBinding. This function indicates that the field we are binding is an account level field. Within the case statement in this function, we’ll want to add a reference to the Division field like this:
This can be added anywhere in the case statement BEFORE the case else at the end.
The next function in the script is named OnAddEntityBindings(). This is where the actual binding takes place. Within this code, you’ll need to add a line binding the Division field to a new text control we’ll call “txtDivision”.
BindingSource.Bindings.Add(new WebEntityBinding(“Account.Division”, txtDivision, “Text”));
Next, add a reference to the new control in the function Named “lueUseExistingAccount_ChangeAction“. This function just disables the account controls on the form and uses the values from the selected account to set certain contact fields. We’ll just need to add a line to disable our new control.
ownAccountOwner.Enabled = false;
Next, on the LoadView() method, you’ll need to add a reference to the control in the area where the other account level controls are referenced. It’s within the If statement looking to see if account != null.
txtDivision.Enabled = changeEnable;
That is all the changes we need to make in terms of the C# code, however we haven’t yet placed the control itself of the form.
We can replace the code defining Business Description with the code for our new control (everything including the <td> tags:
<span class=”lbl”><asp:Label ID=”txtDivision_lz” AssociatedControlID=”txtDivision” runat=”server” Text=”Division”></asp:Label></span>
<span class=”textcontrol”><asp:TextBox runat=”server” ID=”txtDivision” /></span>
And that is all there is to it! We now have a brand new Division field on the Insert Contact/Account view in the web client.