Escolar Documentos
Profissional Documentos
Cultura Documentos
5 Lesson 1
Lesson 1
Basic Customizations
This lesson provides a chance to practice basic customization skills learned in the
Introduction to Developing for Sage SalesLogix LAN v7.5 course. You will also
complete a series of exercises to enhance the original project (DevIntro) to track
courses and enrollments.
You will learn how to:
z Install the DevIntro bundle, and review the customizations to become familiar
with the SalesLogix Architect.
z Add customizations to the DevIntro project
Installing a Bundle
Bundles are saved in files with the extension .sxb, and work with any database type.
You can install a bundle using the Bundle Manager in the SalesLogix Administrator
(Nav Bar > Bundles). The Bundle Manager controls the installation and removal
of bundles in your SalesLogix database.
SalesLogix installs bundle components in the order listed on the Scripts tab in
Bundle properties. All plugins contained in SalesLogix bundles are identified by the
version number when they were last modified. Version numbers are represented by
a four-decimal float field (####.####), which allows differentiation between major,
minor, patch, and hot fix releases. For example, plugins that were modified for
SalesLogix version 6.2, Service Pack 1 display as version 6.2.1.
With this version system, any existing plugin will not be removed or modified when
you apply a bundle containing the same plugin, unless the plugins have a duplicate
name, family, type, company, and company version.
NOTE: In the classroom, your trainer has already created a connection to a Development
database, which is a back-up of the SalesLogix Evaluation database. You will use
Development in all connection strings later in this course. Your trainer has also modified
the appropriate logging paths for the SYNCSERVER, SYNCSERVICEFILE, and
BRANCHOPTIONS tables when setting up the development environment.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the step-by-step instructions.
Exercise 1.1 on page 149
Quick Steps
After reviewing the following criteria, start the exercise.
1. Install the bundle used in the Introduction to Developing course.
z Log on to the Administrator. Create a DEVELOPMENT database
connection and data link.
z Use the DevIntro.sxb file, which is located in the ClassFiles folder on your
desktop.
z Do not update any releases.
2. Review the plugins installed.
3. Review the table schema used in the project.
Ready, Set, Go!
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
The Course Enrollment data grid appears as a tab on the Contact Detail view.
When you right-click in the data grid and click Add Enrollment, the Insert New
Enrollments form appears, which allows you to add and edit enrollments.
The Insert New Enrollments form opens a lookup when you click the Search
button next to the Course Name box. The lookup allows you to search for all
courses by course name.
When you click the Courses button, a Course main view appears. The Course
Detail view includes a Course Detail form and a Contact Enrollments data grid.
Each column has standard properties. In the next exercise you will use the following
properties:
z Read Only
z Disable Editor
z Format and Format/String
In addition to standard properties, each column type has specific properties.
Column types include Check, Combo, and more. In the next exercise you will use
the Check column type.
NOTE: In most cases, settings entered through the DataGrid Columns property overwrite
formatting settings entered through the Query Builder. Exceptions include Visibility, Read
Only, and Width.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the step-by-step instructions.
Exercise 1.2 on page 158
Quick Steps
After reviewing the following criteria, start the exercise.
1. Create a new Architect project named DevAdvanced, and add the
C_EnrollDataGrid form from the DevIntro bundle to the new project.
2. Apply the specified properties and formatting to the columns in the data grid.
Column Read Only Disable Editor Format Format String Column Type
Course
Selected Selected None Standard
Name
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
You can edit only the Paid column directly from within the Course Enrollment
data grid.
The data grid should have appropriate formatting for each column (refer to the
following figure).
Working Ahead
If you finished this exercise early, complete the following Quick Steps to enhance
the project. These steps are not required to continue with the exercises.
1. Add the C_ContactEnrollDataGrid form to the DevAdvanced project.
2. Apply the specified properties and formatting to the columns in the data grid.
Mailing City/State/
Selected Selected None Standard
Zip
3. Increase the Width property for the Email and Mailing columns.
When finished, the data grid should have appropriate formatting for each
column (refer to the following figure):
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the step-by-step instructions.
Exercise 1.3 on page 163
Quick Steps
After reviewing the following criteria, start the exercise.
1. Use an existing lookup to retrieve the ContactID and Contact Last Name for use
on the form.
2. Create a new data form (C_ADDEDITContactEnrollment) to allow users to
add/edit an enrollment. The form should have the following controls:
z ReadOnly: selected
EditBox edtCourseName z Enabled: cleared
z Color: clBtnFace
z HideButtonIfReadOnly: cleared
z Lookup: (CONTACT:Lastname)
LookupEdit lkpContactName
z LookupID: (C_ENROLLMENT:CONTACTID)
z Required: selected
CheckBox chkPaid
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
When you right-click in the data grid and choose Add Enrollment, the Insert
Contact Enrollments Information window (C_ADDEDITContactEnrollment)
appears.
When you click Search next to the Contact Name box, the lookup by contact last
name appears.
Working Ahead
If you finished this exercise early, complete the following Quick Steps to enhance
the project. These steps are not required to continue with the exercises.
1. Remove the More Tabs option from the Courses main view.
2. Set the Contact Enrollment tab as the default.
3. Change the Course main view to display the CourseName in the Lookup Bar
(Title Bar).
When finished the main view should look similar to the following figure:
4. Remove the warning message to users about displaying a large data set.
TIP: Use the Architect Help to look for the “Set General Client Options” topic.
1. What properties would you set on a data grid column to make the column Read
Only and so the user cannot click into the cell?
a. ReadOnly selected
b. Disable Editor selected
c. Cursor set to arrow
d. Enabled cleared
3. What properties must be set on a data grid in order to allow an Add/Edit form?
a. ____________________________________
b. ____________________________________
5. How do you remove the warning “This group is potentially large. Are you sure
you want to open it?” from displaying?
______________________________________________________________
______________________________________________________________
Lesson 2
Basic Programming
This lesson provides a chance to practice basic programming skills. You will
complete a series of exercises to create a customization project that uses scripts to
enhance functionality.
You will learn how to:
z Customize a manage form
z Create scripts in SalesLogix
z Use data validation
z Implement object-oriented-programming concepts in your customizations
In the next exercise you will need to familiarize yourself with the following
functions from the Application.BasicFunctions object:
z CurrentAccountID: Returns the current account ID.
z CurrentAccountName: Returns the current account name.
In addition, you should also familiarize yourself with the ADO Connection object,
which allows a connection to your datasource and allows you to execute SQL
against your database. In the next exercise you will use the following method:
Application.GetNewConnection: Built-in SalesLogix function that returns a valid
connection based on your datalink.
Finally, you should also familiarize yourself with the ADO Recordset object,
which is returned from the ADO command object execute method or the ADO
connection object execute method.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the detailed steps.
Exercise 2.1 on page 170
Quick Steps
After reviewing the following criteria, start the exercise.
1. Create a manage form. Add a button to the form (Click Me) that uses an
OnClick event.
2. Add a new label (Account Name and ID:) and edit box to the manage form.
3. Use the Application.BasicFunctions object to retrieve the account name and ID,
and display the data in the same edit box.
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
The Dev Course menu is merged with the Standard Menu Bar and includes a Hello
World menu item
NOTE: Because the form is a manage form, it is not tied to an existing main view table;
therefore, it is not automatically displayed in a main view’s More Tabs area.
The form displays an empty edit box when launched from the Dev Course >
Hello World menu.
When you click the Click Me button, the Hello World message box appears and the
current account name and ID appear in the edit box.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the detailed steps.
Exercise 2.2 on page 177
Quick Steps
After reviewing the following criteria, start the exercise.
1. Create a new function called GetContactCount.
TIP: You can copy and paste from the Snippet1.txt file in the ClassFiles folder to
get started.
TIP: Make sure you set the objects to nothing and close the connection object when
finished.
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
TIP: Make sure you are viewing the Account main view before testing the customization.
The form launches from the Dev Course > Hello World menu.
When you click the Click Me button, the Hello World message box appears with
the record count text below the “Hello World” text.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the detailed steps.
Exercise 2.3 on page 180
Quick Steps
After reviewing the following criteria, start the exercise.
1. Add a new label (Description of Business:) and memo box to the form.
2. Add a button to the form (Save) that uses an OnClick event. The sub procedure
should include a SQL UPDATE statement and the Connection object
EXECUTE method to update the business description.
TIP: Make sure you use the BusinessDescription field; not the Description field.
TIP: You can copy and paste from the Snippet2.txt file in the ClassFiles folder to
get started.
3. Display the number of records updated on a message box when a user clicks the
Save button.
Ready, Set, Go!
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
TIP: Make sure you are viewing the Account main view before testing the customization.
The form launches from the Dev Course > Hello World menu.
After you click Click Me, update the Business Description, and then click Save, a
message box appears that indicates the number of records affected.
After you close the form, navigate to the next record in the list, and then navigate
back to the original record, the Business Description in the Detail area
automatically updates.
Working Ahead
If you finished this exercise early, complete the following Quick Steps to enhance
the project. These steps are not required to continue with the exercises.
1. Use the Application object to display the Business Description data from the
Account Detail area in the memo box on the C_HelloWorldForm open event.
2. After you click Save, refresh the Account Detail form.
3. Update only if the Business Description box (on the manage form) is not blank.
4. Add hot-key functionality to all the buttons on the form.
When finished, the manage form and the Account Details form should update
from either location (if conditions are satisfied), and both buttons should be
accessible through hot keys.
5. How could you use the SLX Database Support script to manage the connection
and execution of the UPDATE statement?
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
______________________________________________________________
TIP: Do not set the debug mode to Always because SalesLogix launches debugging for
every line of code, whether it contains an error or not.
Within the SalesLogix Debugging mode in Visual Studio, you can choose from
several options under the Debug > Windows menu:
z Watch: Allows you to watch a certain variable or set a stop command when a
variable reaches a certain value.
z Immediate: Allows you to ask a question or set a variable to a certain value.
z Locals: Allows you to see what variables are currently in scope.
TIP: Use built-in SalesLogix Error Handling functions to help you out!
Detailed Steps
This exercise is designed to walk you through the debugging features in Visual
Studio. Using your C_HelloWorldForm form, you will conduct a series of steps that
help you learn how to:
z Step into and step over code
z Use the Immediate Window
z Add and modifying code to the Watch list
z Use the err.description property
Refer to the following page to locate detailed steps.
Exercise 2.4 on page 184
Quick Steps
There are no quick steps for this exercise.
Detailed Steps
This exercise is designed to walk you through the debugging features in Visual
Studio. Using your C_HelloWorldForm form, you will conduct a series of steps that
help you learn how to:
z Use On Error Resume Next
z Use the ErrorCheck procedure within the SLX Error Support script
z Display custom error messages by using the err.number property
Refer to the following page to locate detailed steps.
Exercise 2.5 on page 191
Quick Steps
There are no quick steps for this exercise.
Scripts
Before you start the next exercise, you should understand the following topics:
z Using manage forms (covered in Project 3)
z Using menus (covered in Project 3)
z Using combo boxes with script
When users enter data into the combo box, either by typing text or selecting an item
from the list, the value of the Text property changes. The list of items displayed in
a combo box is stored in the Items property.
Use the Items property to load the items into the control. The user can select a value
from the combo box and other procedures can use that value.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the detailed steps.
Exercise 2.6 on page 197
Quick Steps
After reviewing the following criteria, start the exercise.
1. Append a new Course menu item (C_ADDCourseMenu) to the standard
SalesLogix Client Insert menu after the Campaign menu item to launch a new
Add a New Course manage form (C_ADDCourse).
2. Populate the Price combo box through VBScript in the form Create event.
Format the values as currency and range from $300-$2100 with increments of
$300 using a For Next loop.
3. Populate the No of Places combo box (6 and 12) through VBScript in the form
Create event. Do not use a loop. Default to 12 using ItemIndex in VBScript.
4. The controls on the form should function the same way as the controls on the
Course Details form (C_CourseDetail). You may want to copy and paste these
controls on the new form.
Additionally, you should modify the default manage form buttons:
Control Properties
z Caption: OK
Button z Name: btnOK
z Functionality: Doesn’t do anything yet. You will add the
functionality to save the data in a later exercise
z Caption: Cancel
Button z Name: btnCancel
z Functionality: This button should close the form. This
functionality works without the use of code.
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
The Add a New Course form (C_ADDCourse) has functioning controls for Course
Name, Start Date, End Date, Instructor, Price, No of Places, and Room.
The No of Places combo box has values of 6 and 12, with default set to 12.
The Price combo box has values of $300, $600, $900, $1200, $1500, $1800, and
$2100 (formatted as currency).
Data Validation
Before you start the next exercise, you should understand the following topics:
z Using ModalResult
z Using AXFormCloseQuery
z Using VBScript built-in date functions
z Using Include Script and SLX_Util
Using ModalResult
All buttons have a property called ModalResult. The default value of this property
is set to ‘mrNone’. If you set the ModalResult to any other value, you can check to
see which button the user clicked when different form events are triggered. You
check to see the value by referencing the variable ModalResult in your code.
Some examples of ModalResult values include mrCancel, mrOK, mrYes, mrNo,
mrNone, and more.
Using AXFormCloseQuery
This function is called when the onCloseQuery form event is fired. You can
reference and set the value AXFormCloseQuery from within the
AXFormCloseQuery function. The function returns TRUE or FALSE.
Value Description
The default for this property is set to True, which means the form
True
will close if you do not set or use this property.
Function Description
Valid interval values include the following: "d" (day), "m" (month), "yyyy" (year),
"q" (quarter), "ww" (week), "h" (hour), "n"(minute), "w" (weekday), and more.
All available script and VBScript plugins are available for you to use. In the System
family, the SLX_Util plugin provides several functions that you can use when
validating data on a form. Some of the functions include the following:
z ShowMessage(msg)
z ShowError(msg)
z ShowQuestion(msg)*
z ShowWarning(msg)
z ShowWarningQuestion(msg)*
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the detailed steps.
Exercise 2.7 on page 203
Quick Steps
After reviewing the following criteria, start the exercise.
1. If the user selects a Start Date, manipulate the End Date using the OnChange
event of startdate populates with a date two days from the selected Start Date.
2. Create a function called IsWeekend(). Use the datepart function to determine if
the date is a weekend.
z Parameter: Date
z Returns: T/F
3. Create a function called ValidateCourse() to run when the OnCloseQuery
event fires.
z Parameter: none
z Returns: T/F
z Displays: A message box with validation errors using SLX_Util script and
an appropriate function.
z Business Rules:
z Start Date and End Date cannot be on a weekend.
z End Date cannot be less than the Start Date.
z Start Date cannot be greater than the End Date.
z All fields are required.
TIP: You can copy and paste from the Snippet3.txt and Snippet4.txt files in the
ClassFiles folder to get started.
4. Close the form without validating any data if the user clicks Cancel. Use the
AXFormCloseQuery with the ModalResult value to determine if the user
clicked Cancel or OK.
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
Verify the Start Date and End Date fields only allow entries as outlined in the
business rules.
If a field does not pass validation, a message box appears, which tells you what
fields do not pass validation, and the form does not close.
Working Ahead
If you finished this exercise early, complete the following Quick Steps to add
additional validation to the form. These steps are not required to continue with the
exercises.
1. The Price should be greater than 0 and in an increment of $300.
2. The Number of Places should be greater than 0 and 12 or less. Also, the
available seats should be in increments of 6 (either 6 or 12).
TIP: You can use one of several ways to do this, but can also use the MOD function.
TIP: You can use a combination of the IsWeekend function and the DateAdd function.
5. Verify no Start Date or End Date spans more than 6 days total. The longest
class can be 5 days.
6. If the user entered an invalid value, change the color to vbRed.
NOTE: In this case, you will use a constant variable because a name is easier to remember
and you will use it to store several SQL constants in one location so the SQL is easier to
find in case of a change.
Detailed Steps
This exercise is designed to give you enough criteria to complete the exercise on
your own. If you need to reference step-by-step instructions, refer to the page shown
below. Try to complete as much of the exercise using only the quick steps below
before consulting the detailed steps.
Exercise 2.8 on page 208
Quick Steps
After reviewing the following criteria, start the exercise.
1. Change the AXCloseQuery function to call a Save sub that uses the
DataCommand class.
2. Create a VBScript plugin to contain parameterized SQL statements. Also create
a SQL INSERT statement using ? for parameters. Make this a Const.
3. Create a VBScript plugin to contain a DataCommand class.
TIP: You can copy and paste from the Snippet5.txt file in the ClassFiles folder.
This class should have the following methods, events, and properties:
Quick QA
After completing the exercise, log on to the SalesLogix Client as admin. Use the
following check list to verify you completed all the required steps.
Open the Add a New Course form from the Insert > Course menu. Fill in all the
required information. When you click OK, a message box should appear to indicate
whether or not the save was successful.
The new course should be recorded to the database. Open SQL Enterprise Manager
to view the new record in the back-end.
Working Ahead
If you finished this exercise early, complete the following Quick Steps to add
additional functionality to the DataCommand class. These steps are not required to
continue with the exercises.
1. The size of the parameter is determined through code. Change the AddParam
method and plan for additional data types. Add additional IF/THEN logic that
plans for the adLongVarBinary with size 8, an empty value, which would be a
NULL of size 2, and other types of strings.
TIP: Research on the Internet to find out which data types need a size and what sizes they
need to be.
2. Remove the SQL parameter passed into the EXECUTE method and create a
SQLText property. If you set the SQLText property BEFORE you do the
AddParam method, you will load the default parameter types and sizes. This
makes it unnecessary to specify the type and size properties with AddParam.
Why does this happen?
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
What are the benefits to using this approach?
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
What are the cons of using this approach?
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
_____________________________________________________________
3. What SQL statement returns a count of the contact table in a one row recordset?
a. Select * as count from Contact
b. Select count(*) from contact
c. Select count(ID) from contact
d. You cannot return the count of a table.
4. What is the correct syntax for returning a recordset using the Execute method
of the Connection object?
_____________________________________________________________
5. To add a value to a combo box through script, what combo box collection
should you use?
a. Item
b. Items
c. Add
d. Display
8. What benefits are possible when you use the Command object to execute your
SQL statements? (Circle all that apply.)
a. You do not have to guess at the data types.
b. You do not have to use concatenation and string quotes
c. They replace stored procedures
d. They execute faster
e. You can use parameters
f. There are no benefits; I'm going to continue to use inline SQL!