Pivotal Business Server Customization Fundamentals
Pivotal Business Server Customization Fundamentals
Pivotal Business Server Customization Fundamentals
Services
Student Workbook
International
Version 2.0
The Pivotal name and logo and all related product and service names, design marks, and slogans are
the trademarks, service marks, or registered trademarks of CDC Software Corporation.
Microsoft is a registered trademark of Microsoft Corporation. All other company or product names
appear in this guide are for identification only and may or may not be trademarks or registered
trademarks of their respective holders.
Pivotal 360o eBusiness Relationship Management Software is licensed and subject to the conditions
and limitations of the Pivotal License.
The information herein is the property of Pivotal and any misuse or abuse will result in economic
loss. DO NOT COPY UNLESS YOU HAVE BEEN GIVEN SPECIFIC WRITTEN AUTHORIZATION
FROM PIVOTAL.
CONFIDENTIAL INFORMATION
This document is provided for limited and restricted purposes in accordance with a binding contract
with Pivotal. The information herein includes trade-secrets and should all be considered confidential.
DISCLAIMER
THE INFORMATION IN THIS DOCUMENT WILL BE SUBJECT TO PERIODIC CHANGE AND
UPDATING. PLEASE CONFIRM THAT YOU HAVE THE MOST CURRENT DOCUMENTATION.
THERE ARE NO WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, PROVIDED IN THIS
DOCUMENTATION, OTHER THAN THOSE EXPRESSLY AGREED UPON IN THE APPLICABLE
PIVOTAL CONTRACT. ERRORS AND OMISSIONS EXCEPTED.
Page: 2 of 128
Copyright CDC Software Corporation
Contents
Module 1: Rich Client Review ...............................................................................................................................5
Module 2: Installation.............................................................................................................................................7
Exercise 2.1: Install and Test Rich Client ..........................................................................................................8
Exercise 2.2 Configure a Customization System..............................................................................................13
Module 3: Customization Process ........................................................................................................................19
Exercise 3-1: Optimizing the LCS....................................................................................................................20
Exercise 3-2: Shut down the MTS....................................................................................................................21
Module 4: Customizing the Presentation Layer ...................................................................................................22
Exercise 4-1: Customizing the Logo ................................................................................................................23
Exercise 4-2: Setting Security for the Rich Client............................................................................................24
Exercise 4-3: Global Quick Search ..................................................................................................................26
Exercise 4-4: Table eTab Menu Items..............................................................................................................27
Exercise 4-5: Parent eTab menu items .............................................................................................................29
Exercise 4-6: Editing Active Forms .................................................................................................................30
Exercise 4-7: Adding Secondary Segments to an Active Form........................................................................34
Exercise 4-8: Adding Automation to an Active Form......................................................................................36
Exercise 4-9: Create an Active Search and an Active Search Result ...............................................................37
Exercise 4-10: Refining the Search Result .......................................................................................................39
Exercise 4-11: Customizing the iTab ...............................................................................................................41
Exercise 4-12: Customizing the Home Page ....................................................................................................43
Module 5: Data Flow Client ..............................................................................................................................45
Module 6: Debugging Client Scripts ....................................................................................................................47
Exercise 6-1: Using Debug Tools.....................................................................................................................47
Module 7: Client Libraries ...................................................................................................................................48
Module 8: Developing Client Scripts ...................................................................................................................50
Exercise 8-1: Creating a Field Script................................................................................................................51
Exercise 8-2: Creating Form Script Functions .................................................................................................53
Exercise 8-3: Adding business logic to a Form Script .....................................................................................55
Exercise 8-4: Calling a Global Script Function................................................................................................56
Exercise 8-5: Add Transition Points from Client to Server - Part 1 .................................................................57
Exercise 8-6: Add Pre-Processing to a Transition Point ..................................................................................58
Module 9: Data Flow - Server ..............................................................................................................................59
Module 10: .net Assemblies and Interops ............................................................................................................61
Module 11: Developing AppServer Rules............................................................................................................63
Exercise 11-1: Create a new AppServer Rule ..................................................................................................64
Exercise 11-2: Update and Debug Transition Point .........................................................................................69
Challenge Exercise Module 11: Updating Active Form Behavour ..................................................................71
Module 12: Coding the Execute Transition Point ................................................................................................72
Exercise 12-1: Coding the Execute Transition Point.......................................................................................73
Module 13: Error Handling ..................................................................................................................................75
Module 14: Using the Language Dictionary ........................................................................................................77
14-1: Using the Language Dictionary ..............................................................................................................78
Challenge Exercise Module 14: Extending Language Translation Facilities ...................................................80
Module 15: Various Coding Exercises.................................................................................................................82
Exercise 15-1: Adding automation to a form ...................................................................................................83
Exercise 15-2: Cancelling Record Deletion .....................................................................................................86
Exercise 15-3: Cascading Record Deletion ......................................................................................................87
Exercise 15-4: Running a report from Code.....................................................................................................88
Exercise 15-5: Handling Other Platform Events ..............................................................................................90
Appendix: Script and Code Samples ....................................................................................................................92
Exercise 8-1 ......................................................................................................................................................93
Exercise 8-2 ......................................................................................................................................................94
Exercise 8-3 ......................................................................................................................................................96
Exercise 8-4 ......................................................................................................................................................99
Exercise 8-5 ....................................................................................................................................................101
Exercise 8-6 ....................................................................................................................................................102
530: Business Server Customization Fundamentals
Student Workbook International Version 2.0
Page: 3 of 128
Copyright CDC Software Corporation
Page: 4 of 128
Copyright CDC Software Corporation
Page: 5 of 128
Copyright CDC Software Corporation
Page: 6 of 128
Copyright CDC Software Corporation
Module 2: Installation
Page: 7 of 128
Copyright CDC Software Corporation
Completed Steps
The local NT account PRAC (Pivotal Relationship Account) has been created for you so that that it can be used
to run the MTS service. Note that this account has been created with the following properties.
Username
Password
NT local group membership:
SQL Permissions
PRAC
universe
Users, Administrators
Login created with access to
the ProductionBM and
ProductionED databases.
Grated Local Logon and Log
On As a Service rights
3. Right mouse click on the applet Lifecycle Engine AppServer, and select properties. Expose the
Identity Tab. Select the radio button This User and the login detail for the user PRAC. As shown
below.
Page: 8 of 128
Copyright CDC Software Corporation
4. Click on OK
5. Close the Component Services console
Page: 9 of 128
Copyright CDC Software Corporation
Page: 10 of 128
Copyright CDC Software Corporation
8. Click Next
9. Click Install
10. When the installation is complete, click Finish.
group.
3.
Page: 11 of 128
Copyright CDC Software Corporation
2.
For ease of use place a shortcut to this URL on your windows desktop
Page: 12 of 128
Copyright CDC Software Corporation
Tasks
Install Pivotal Toolkit
1.
2.
3.
4.
5.
6.
7.
Step
1. Ensure you are logged in as PRAC,
Tool Required
Windows Server 2003
Page: 13 of 128
Copyright CDC Software Corporation
6. Start the application. The menu path to this application is Start->Programs->Microsoft SQL
Server 2005-> SQL Server Management Studio.
7. When prompted to confirm connection lick on the Connect button
8. To create a new database, right mouse click on the Databases folder and select new database.
Page: 14 of 128
Copyright CDC Software Corporation
9. To check permissions for a specific user. Use the Object Explorer window open Security and
Login folders. Right-click on the relevant user and select properties.
Page: 15 of 128
Copyright CDC Software Corporation
10. In the new dialogue you must select User Mapping and ensure that the user (PRAC) has dbo
access to the customisation (toolkit) module and also dbo access to ProductionBM
Page: 16 of 128
Copyright CDC Software Corporation
2. Now, click on the Connect button, the properties dialogue will be updated as shown below
3. Ensure the license file Pivotal Customisation is selected and click on the Set License File button
Page: 17 of 128
Copyright CDC Software Corporation
Assigning Licenses
12. Using eRelationship Enterprise Manager you should connect to the systems so that you can see all
the users for that system. Right-mouse click on the PRAC user and select Assign License as
shown below.
Page: 18 of 128
Copyright CDC Software Corporation
Page: 19 of 128
Copyright CDC Software Corporation
Tasks
13. Start the LCS Customization Assistant.
14. On the Development Settings tab, within the Lifecycle Server Initialization Options dialog, check
Disable AppServer Rule Synchronization and Disable Full-Text Search.
15. Still on the tab, check the options for Automatic Client Script Reload and Enable Script
Debugging. This option will be useful in later exercises.
Page: 20 of 128
Copyright CDC Software Corporation
Tasks
Add a new item to the Rich Client eTab
1. Within the Customization System, open Security.
Note We will cover security in detail in an upcoming exercise.
2. Expand the Base CMS Features security group and select the Active Access connection.
3. On the Tables tab, make the Telemarketer table readable.
4. On the Business Object tab, make the Telemarketers object visible.
5. Save your security changes.
Component Services
Computers
My Computer
COM + Applications
3. Right click on the Lifecycle Engine AppServer and select Shut down.
4. Re-start the Rich Client. Search the eTab for the Telemarketer item.
Reset Security
1. Re-set the security, removing the permissions you previously granted on the Telemarketer table
and Business Object.
Page: 21 of 128
Copyright CDC Software Corporation
Page: 22 of 128
Copyright CDC Software Corporation
Tasks
Change the Corporate Logo
1. Start the Rich Client
2. On the Home Page, right-click the Company Logo and select Properties.
3. Look at the Address: (URL) to determine which scheme you are using.
Page: 23 of 128
Copyright CDC Software Corporation
Tasks
Create a New Security Group
1. In the Customization System, click the Security tab on the eTab.
2. Create a new group by right-clicking in the white space and selecting New Group. Name the
group "Rich Client Group".
Company
Contact
Employee
Reports
Saved_List_Items
Saved_Lists
Saved_Lookups
Companies
Contacts
Employees
Queries
Reports
Static Lists
Search Visible
Company
My Companies
Companies of Account Manager?
Contact
Page: 24 of 128
Copyright CDC Software Corporation
Active Employees
Active Form
Company
Company
Yes
Yes
Contact
Contact
Yes
No
Employee
Employee
Yes
Yes
Saved_Lis
t
Saved Lists
Yes
No
Page: 25 of 128
Copyright CDC Software Corporation
Tasks
Make a field desktop findable
1. Within Rich Client, do a Global Quick Search for Canada. What are the results? [Answer - no
Companies, Contacts, Opportunities, Competitors, Groups, Order Capture, or News]
2. Within your Customization System, open the Company table and open the Country field.
3. In the table field form, click the option Desktop Findable.
4. Save the changes.
5. Re-start the MTS and Rich Client.
6. Test the functionality by doing a Global Quick Search for Canada. How many companies are
returned? [Answer: 5]
Page: 26 of 128
Copyright CDC Software Corporation
Tasks
Add a table eTab menu item
Within the Customization System, transport in the file Suggestion Table.rtr from the code disk
directory (C:\Course Files\Module 4). This .rtr contains the definition for the Suggestion table.
Do not forget to Apply Customization Changes.
1.
2.
3.
4.
5.
6.
2. In the windows form editor, click the button Save As Active Form. When prompted for a form
name change the name to Suggestion.
3. If you wish, you can review the form in the active form editor. Select Active Forms->Active
Forms by Table. Open the suggestion branch and click on the form Suggestion.
Page: 27 of 128
Copyright CDC Software Corporation
What submenu items are listed for the Suggestion menu item? Why is it that there are no records
for each submenu item?
Set Permissions for Active Form
1. In the customisation system access the Base CMS Feature security group
2. Open the Active Access Permissions
3. Make the active form scriptable and default as summarised below
Table
Active Form
Suggestio
n
Suggestion
Yes
Yes
There are two ways you can make the Suggestions item appear higher up the menu, how do
you do this
Answer 1
_________________________________________________________
_________________________________________________________
Answer 2
_________________________________________________________
_________________________________________________________
Test the Form
1. Use this new active form to enter some suggestion records into the system
Page: 28 of 128
Copyright CDC Software Corporation
Tasks
Create a parent eTab menu item
1. Within the Customization System, click the Business Objects tab and choose New Business
Objects.
2. Create and save a Business Object using the following parameters:
Parameter
Value
Name
Entertainment
Ordinal
<Next Ordinal>
Icon
<Your Choice>
NOTE: Icon not used in Rich Client but is required as it is used in the Windows Client.
3. Save your changes.
Value
Name
Sports Results
Ordinal
<Next Ordinal>
Icon
<Your choice>
Parent
Entertainment
URL Tab
http://sports.yahoo.com/
Open Link
in
Separate
Window
<Checked>
Page: 29 of 128
Copyright CDC Software Corporation
_________________________________________________________________________
_________________________________________________________________________
Tasks
Add new tabs to the form
The suggestion active form has already been created with a single anchored tab that holds a
single primary segment. We need to introduce additional tab that appear underneath the
contents of the anchored tab.
1. Select Active Forms->Active Forms by Table. Open the suggestion branch and click on the form
Suggestion.
2. Within the form editor right-click on the form element in the left hand navigation pane and select
the option. New.->Tab
3. Browse to the new tab in the left hand navigation pane right-click on the tab [New Tab] select
properties. Update the properties as shown below.
4. Click on OK
5. Repeat steps 1-4 for another tab ; Name; Review, Title: Review
These tabs now sit underneath the segment in the anchored tab.
Page: 30 of 128
Copyright CDC Software Corporation
The left pane should look like the sample shown below.
Page: 31 of 128
Copyright CDC Software Corporation
Improve Layout
1. Browse to the anchored tab; add new segments to this tab, with the following properties and move
fields from the segment suggestions into these new segments as shown below.
Segment
Properties
Fields
Suggested_by_Contact
Name: Suggested_by_Contact
Suggested_By_Contact
Title: Suggested_by_Contact
Column Count: 3
Hide Title; Checked
Employee_Details
Name: Employee_Details
Employee_Id
Title: Employee_Details
Department
Column Count: 2
Hide Title; Checked
Contact_Details
Name: Contact_Details
Contact_Id
Title: Contact_Details
Company_Id
Column Count: 2
Hide Title; Checked
2. In the left-pane, browse to the primary segment suggestion, right click and separator.
A new separator is added to the segment move this up the segment until it is immediately below
the field Date.
3. Repeat step 2 until the left pane looks like the sample shown below
Page: 32 of 128
Copyright CDC Software Corporation
4. Right-mouse click on the field Subject and change the properties as follows
Col Span: 3
Width (EM): 40
You should see your new Suggestion Active form in the SmartPortal main window.
4. Add a few Suggestions.
Page: 33 of 128
Copyright CDC Software Corporation
Tasks
Add the foreign key fied Suggestion_Id to the Rn_Appintments table.
1. In the toolkit edit the table Rn_Appointments
2. Add a new field Suggestion_Id. Ensure this field uses the Reference Id 40+5 and is a foreign key
to the Suggestion_Id primary key in the Suggestion table.
3. What other steps should you complete before you test your customisations?
______________________________________________
______________________________________________
Add a Secondary Segment
1. Within the Customization System, open the Suggestion active form for modification.
2. Right-click the Active Form [Suggestion] item in the left-pane, and choose New -> Tab. A new
Tab is added with the Suggestion [Primary] segment on the Tab.
3. Right-click on the new tan, select Properties and set the name and title Activates
4. Right-click the Activities tab in the left-pane, and choose New ->Secondary Segment.
5. Right-click the New Segment [Secondary] item and choose Properties. Change the Name and
Title to Activities, Click the Link Field and select the Rn_Appointments[Suggestion_Id] field.
6. Click OK to save your changes.
7. Notice what is entered in the Activities[Secondary] segment. Without looking ahead to the next
set of steps, how do you think we can add fields to this segment?
______________________________________________
______________________________________________
Adding Secondary Fields
1. Right-click the Contacts [Secondary] segment and choose New Field->Rn_Appintement_Id.
2. Change the Title of the Rn_Appintement_Id field to Activity.
3. View the Activities [Secondary] properties and ensure the segment can be collapsed and that
users are prohibited from being able to delete any records.
4. Click OK to save your changes to the secondary segment.
5. Save and close the form.
6. Enable and View Changes
7. Apply your changes and re-start the Active Access to view the results.
530: Business Server Customization Fundamentals
Student Workbook International Version 2.0
Page: 34 of 128
Copyright CDC Software Corporation
8. Are you able to add Contacts to the Suggestions? Why or why not?
______________________________________________
Page: 35 of 128
Copyright CDC Software Corporation
Tasks
Transport in a Script
1. Using the Pivotal Transporter, transport into the Customization System the Suggestion Script.rtr
file.
Add a Button
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
Page: 36 of 128
Copyright CDC Software Corporation
Tasks
Create a Target Query
1. Within the Customization System, create a Target query that returns all Suggestions with a
severity of Medium.
2. Save the Target Query as Medium Suggestions.
3. Close the Query window.
Create a Search
1. Click the Active Searches Business Object and choose New Search.
2. Fill in the parameters using the following table:
Parameter
Name
Value
Medium Suggestions
Title
Table
Suggestion
Query
Medium Suggestions
3. Click Save to save your changes and close the Search form.
Parameter
Name
Value
Suggestion Results
Tables
Suggestion
Suggestion_Id
Severity
Type
Contact_Id
Date_
Assigned
Note For all the associated fields, mark as Default, Visible, and Unsorted.
3. Re-open the Date_ field and set its Sort Order to Descending and its Sort Priority to 1.
4. Click Save to save your changes and close the form.
Page: 37 of 128
Copyright CDC Software Corporation
Within Security, open the Active Access connection for the Base CMS Features group.
On the Search Results List tab, set the Suggestion Results Search Display to Default.
Click the Searches tab.
Make the Medium Suggestions search visible.
Save your security changes.
Page: 38 of 128
Copyright CDC Software Corporation
Tasks
Create a Parameter-less Query
2. Create a new Target Query based on the Suggestion table that returns all Suggestions of type
Request.
3. Save the Query as Request Suggestions and close the Query Definition window.
Field
Value
Label
Questions
Query
<leave blank>
Field
Type
Operator
Refinement Question
Value
Click Save to save the changes to the Search Result and close the form.
Enable and View Changes
1. Apply your changes and re-start the Rich Client to view the results.
2. Why are the refinements available for all Suggestion searches?
_____________________________________________
_____________________________________________
_____________________________________________
530: Business Server Customization Fundamentals
Student Workbook International Version 2.0
Page: 39 of 128
Copyright CDC Software Corporation
3. What happens when you choose the Request Suggestions search and click Questions? Why?
_____________________________________________
_____________________________________________
_____________________________________________
Page: 40 of 128
Copyright CDC Software Corporation
Tasks
Create an In-Context Tab URL
Create an In-Context Tab URL that displays a Yahoo map for the current company.
Note: This will only work for companies in the US
1. In a new In-Context Tab URL form, specify the parameters using the following table:
Parameter Value
Table
Company
Label
Content
URL
Define the Link URL so that the search can be used by any record in the
Company table. Your expression should look like the one below
Internal
Name
City_Map
Active
Forms
Company
Note The iTab menu item will have a label Map of and then the city name (e.g. Map of New
York). The menu item that you created is not labelled Local Map.
530: Business Server Customization Fundamentals
Student Workbook International Version 2.0
Page: 41 of 128
Copyright CDC Software Corporation
Parameter
Value
Type
Singular
Table
Company
Label
Entertainment in <City>
Plug-in
TicketMaster
Internal Name
Active Forms
Company
Click the Parameters tab, and then click the button. Enter the following parameters.
Input Name
Input Value
City
[City]
Country
[Country]
State
[State_]
Note As this plug-in is for American cities, check the location of the company that you
select for testing.
Verify your iTab customization
1. Display a Company record form. Click the iTab.
2. Click on your Entertainment in <CityName> menu item to verify that your plug-in is successful.
Page: 42 of 128
Copyright CDC Software Corporation
SmartPortal Category
Tasks
SmartPortal Category
1. Right-click the SmartPortal Categories object and choose New 4 SmartPortal Category.
2. Specify the category name as Suggestion.
3. Save the category
Field
Value
Name
Types of Suggestions
Description
Language String
<leave default>
Item Type
<leave default>
Category
Suggestion
SmartPortal Title
Types of Suggestions
3. In the Query tab and Items sub-tab, choose the Suggestion table and specify the All Suggestions
query.
4. Click the Graph tab.
Create a Graph
1. You need to create a Graph before you can select it. Keep the New SmartPortal Content item
open and right-click the Graph Business Object then choose New Graph.
Page: 43 of 128
Copyright CDC Software Corporation
Fields
Value
Name
Types of Suggestions
Type
Bar
Table
Suggestion
Title
Types of Suggestions
Language String
<leave default>
Type
X-axis: Aggregation
None
Type
<leave default>
Suggestion_Id
Y-axis: Aggregation
Count
Number of Suggestions
<leave default>
A graph of all your Suggestions grouped by Type appears in your home page.
Page: 44 of 128
Copyright CDC Software Corporation
Page: 45 of 128
Copyright CDC Software Corporation
Page: 46 of 128
Copyright CDC Software Corporation
Tasks
Add DbgAlert and DbgTrace statements
1. Open the Client Form Script for Company (Company_Form).
2. In the LoadFormData function, prior to the DoLoadFormData call, add a DbgAlert step that
indicates that the form is about to be opened.
3. After the form is opened, add a DbgTrace step that indicates that the form is loaded.
4. Here is an example of how your code should look:
.......
DbgAlert About to open form
vntRecordsets=rfrmForm.DoLoadFormData(vntRecordId,vntParameters)
DbgTrace Form is loaded
......
5. Add the &debug flag to your Rich Client shortcut
6. Right-click on your Rich Client shortcut and add &debug after the system name.
Page: 47 of 128
Copyright CDC Software Corporation
Page: 48 of 128
Copyright CDC Software Corporation
Page: 49 of 128
Copyright CDC Software Corporation
Page: 50 of 128
Copyright CDC Software Corporation
Tasks
Add new segments to the Suggestion From
In this exercise we are going to change the visibility of certain fields. The easiest way to manage this is to
move the relevant fields into their own segments, using the Active Form editor
The left pane should look like the sample shown below.
Page: 51 of 128
Copyright CDC Software Corporation
Page: 52 of 128
Copyright CDC Software Corporation
Tasks
To create a form script for the suggestuion from
1. Create a new Client Script, filling the parameters as follows:
Parameter
Name
Language
Value
Suggestion_Form
VBScript
Note: The appendix contains a sample of a script that will accomplish the desired results - use
this script as a reference.
Page: 53 of 128
Copyright CDC Software Corporation
2.
Page: 54 of 128
Copyright CDC Software Corporation
Tasks
In this exercise, you will update the Suggestion form script to extend the behaviour of the script to
handle the OnFormLoaded event.
Update the form script
1. Edit the form script Suggestion Form
2. Add a new subroutine SetRequired. Use the fields values as summarised below to dynamically
change the attributes of the field in the form
Field: Assigned
Vales
Action
True
Field Assigned_To is Required
Field Severity is Required
False
Field Assigned_To is not Required
Field Severity is not Required
Field: Reviewed
Vales
Action
True
Field Reviewed_By is Required
False
Field Reviewed_By is not Required
3. In the subroutine to handle the platform event OnFormLoaded. Add a call the subroutine
SetRequired to set the necessary field attributes
Note: The appendix contains a sample of a script that will accomplish the desired results - use
this as a reference.
Add new event hook scripts
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Note: The appendix contains sample scripts that will accomplish the desired results - use this as a
reference.
530: Business Server Customization Fundamentals
Student Workbook International Version 2.0
Page: 55 of 128
Copyright CDC Software Corporation
Tasks
Add call to Global.CMSMsgBox
1.
2.
False
Note: The appendix contains sample scripts that will accomplish the desired results - use this as a
reference.
Page: 56 of 128
Copyright CDC Software Corporation
Tasks
Edit the client script Suggestion_Form
1. Implement the following transition points
NewFormData
DeleteForm Data
NewSecondaryData
2. Apply your changes.
3. Test your customization
Note: The appendix contains scripts templates that will show you how to code these transition points.
Page: 57 of 128
Copyright CDC Software Corporation
Tasks
Update client Script
1. Edit the client script Suggestion_Form
2. Add the following functionality to the transition point NewFormData
Using the global method CMSDialigRadio, prompt the user what classification of
suggestion they want to create.
Using the global transition point parameter handling script set up the default value for the
field Classification
Note: The appendix contains scripts templates that will show you how to code these transition
points.
Page: 58 of 128
Copyright CDC Software Corporation
Page: 59 of 128
Copyright CDC Software Corporation
Page: 60 of 128
Copyright CDC Software Corporation
Page: 61 of 128
Copyright CDC Software Corporation
Page: 62 of 128
Copyright CDC Software Corporation
Page: 63 of 128
Copyright CDC Software Corporation
Tasks
Create a new ASR as a C# class library
1. Start the Visual Studio 2005, menu path Start->Programs->Microsoft Visual Studio 2005->
Microsoft Visual Studio 2005
2. In Visual Studio, create a new project menu path File->New. Ensure you have selected a C# class
library as shown below.
3. In the Solution Explorer window, right click on class1.cs and select Delete
Page: 64 of 128
Copyright CDC Software Corporation
4. In the Solution Explorer window, right click on References and select Add. Click on the browse
tab and browse to the folder C:\Program Files\Pivotal\ePower. Using the control key select the
libraries shown below.
Page: 65 of 128
Copyright CDC Software Corporation
8. In Solution Explorer Window right click on the project Suggestion and select Add, from the
dialogue ensure s Class is selected and fill in t he class name Suggestion
9. You can now edit the class library itself ; in the window Suggestion.cs, update the class so that it
looks like the example shown below
Note A sample template is provided in the appendix to show you how the resulting code should
look
Page: 66 of 128
Copyright CDC Software Corporation
4. You should now build the ASR; in the Microsoft Visual Studio 2005, click on Build->Build
Suggestion.
5. Once you have successfully compiled this code, save the project, menu path: File->Save All
Page: 67 of 128
Copyright CDC Software Corporation
3. Find the entry for the ASR Suggestions. You should see and entry similar to the one below.
Page: 68 of 128
Copyright CDC Software Corporation
Tasks
Import Foundation Library ASRs
The .net foundation libraries have their own set of generic Appserver rules that perform various
functions. It is necessary to install these ASRs so that they can be instantiated from the code
that we will write.
1. Open the toolkit
2. Load elements from a transporter file. Menu path Transporter->Import Elements from File.
Browse to the file C:\Program Files\Pivotal\CMS\CMS 5.9\AppServer Rules .NET Starter
Kit\RTR and CSV\CMS r5.9 .NET Foundation Libraries.rtr and click Open
3. Click Continue
4. Click Close
Note: If you want to see all the methods for the TransitionPointParameter class you can see these
in the Object Browser (Menu Path: View->Object Browser). Browse to the library
Pivotal.Application.Foundation.Utility and click on the class TransitionPointParameter
Note: The appendix contains a sample of the changes to the transition point that will accomplish
the desired results - use this as a reference.
Setup Debugging
1. In Microsoft Visual Studio 2005, view the properties for the class suggestion, menu path Project>Suggestion Properties
2. Select the build properties and ensure the output path for Debug and Release configurations is as
shown below is set to
Page: 69 of 128
Copyright CDC Software Corporation
3. Leave the properties tab in Microsoft Visual Studio 2005 open and use the component services
Applet (in eth control panel) to identify the Application ID for the LCS component is on the
general tab as shown below.
4. Copy this Id
5. Return to Microsoft Visual Studio 2005
6. Click on the Debug section and, and click on the radio button Start external program. Choose the
path C:\WINDOWS\system32\dllhost.exe
7. Update the command line parameter to specify the application id you have copied in step 4, ie
/ProcessID:<your copied text>. The properties page for debug section should be similar to one
below.
Page: 70 of 128
Copyright CDC Software Corporation
Tasks
Update Form
1. Edit the active form to make the field Classification read-only
Note: The appendix contains a sample of the changes to the transition point that will accomplish
the desired results - use this as a reference.
Page: 71 of 128
Copyright CDC Software Corporation
Page: 72 of 128
Copyright CDC Software Corporation
Tasks
Add New Event hook Script
1.
2.
3.
4.
Using the primary recordset of the form identify if the Contact_Id fieldis defined.
If it is defined call the Execute transition pount and specify the method name GetSeverity
After the execute transition point has returned extract the first use defined parameter and assign
this to the field Severity
Note: Your appendix contains a sample of a script that will accomplish the desired results - use this script as a
reference.
Access the first user defined parameter (the contact record id) in the transition point
parameter array.
If the contact is of type Customer or Partner set the returned value to 2 (Severity = High)
Using the contact record id again find the record id of the contacts company
Page: 73 of 128
Copyright CDC Software Corporation
Run a query to find all the active opportunities for a specific this company
If there are opportunities retuned, set the returned value to 1 (Severity = Medium)
Pass back the returned value as user defined parameter 1in the transition point parameter
array.
Note: If you want to see all the methods for the TransitionPointParameter class, you can see these
in the Object Browser (Menu Path: View->Object Browser). Browse to the library
Pivotal.Application.Foundation.Utility and click on the class TransitionPointParameter
Note: The appendix contains a sample of the changes to the transition point that will accomplish
the desired results - use this as a reference.
Page: 74 of 128
Copyright CDC Software Corporation
Page: 75 of 128
Copyright CDC Software Corporation
Page: 76 of 128
Copyright CDC Software Corporation
Page: 77 of 128
Copyright CDC Software Corporation
Tasks
Create a new Language.
Note - If you are intending to complete the challeng exercise for this module you will save time by starting the
Populate task of the Language agent see the first task of the challenge exercise for details
1. In the Toolkit create a new LD Language, for Spanish. Fill in the fields as shown below
3. By clicking the + on the language string form, add the following translations.
Note: your will be prompted to save the language string first
Language
Text
Spanish
Page: 78 of 128
Copyright CDC Software Corporation
3. Add code to the above that retrieves the choices for the field Severity.
4. Use this return value in the GetTextSub method of the language dictionary object to get the
translated text for Suggestion Severity string.
Page: 79 of 128
Copyright CDC Software Corporation
Tasks
Populate UI Strings and Labels
1. If you have not already done so, open the toolkit and via the personal assistant start the Pivotal
Agent Langauge.
2. Select the option Populate Language and click on OK
3. When prompted again click on Continue and select the langrage English (United States). This will
take approximately 45 minutes to complete
Text
Suggestion Severity.
Spanish
Severidad de la sugerencia
Page: 80 of 128
Copyright CDC Software Corporation
4. In the toolkit open the Suggestion table and then open the field Severity. If the language agent has
completed correctly, the choice values for this fields populated with language strings, the field
form should be similar to the one shown below.
String Name
Text
0 - Low
Punto bajo
1 Medium
Medio
2 High
Colmo
Page: 81 of 128
Copyright CDC Software Corporation
Page: 82 of 128
Copyright CDC Software Corporation
Tasks
Create a new database relationship
1. In the toolkit, edit the suggestion table
2. Add a new field, the should be a foriehn key (field type reference) to the suggestion table, name:
Suggestion_Id.
3. Save the changes
4. In eREM connect to the production system and Apply Customisation Changes (ACC). When the
proposed changes are displayed click on OK to accept them.
Page: 83 of 128
Copyright CDC Software Corporation
4. Right click on the Actions button set and add New Button Set again. Set the properties; name: New
Activity, title: New Activity.
5. Right click the New Activity s button set and add New Button. Set the buttons properties; name
and title: Call
6. Repeat step 5 for the buttons Meeting, ToDo and Note.
7. Save you changes.
Note - event hooks script will be associated with these buttons later in the exercise once they have
been implemented.
Your appendix contains a sample script that will accomplish the desired results - use this as a reference
Page: 84 of 128
Copyright CDC Software Corporation
Suggestion_NewToDo
Suggestion_NewNote
4. Save your changes
Form.NewActivity(1)
Form.NewActivity(5)
Note: Your appendix contains a sample scripts that will accomplish the desired results - use these as a
reference
Update form
The menu buttons added earlier are now associated with event hook scripts implemented above
5. In the toolkit edit the form Suggestion
6. Locate the buttons Call, Meeting, Todo and Note a associate with an event hook script using the
following table as a reference.
Button
Event
Event Hook Script Name
Call
OnClick
Suggestion_NewCall
Meeting
OnClick
Suggestion_NewMeeting
ToDo
OnClick
Suggestion_NewToDo
Note
OnClick
Suggestion_NewNote
7. Save your changes.
8. Restart LCS and test your changes
9. Add a few activities to a suggestion - will you need the data to test your code in the next exercise.
Page: 85 of 128
Copyright CDC Software Corporation
Tasks
Edit the form Suggestion
Later in this exercise the client script will need to examine the activities associated with a suggestion, in
particular to find the value of the field Activity_Complete in the table Rn_Appointments. This field needs to be
added to the form.
7.
8.
Page: 86 of 128
Copyright CDC Software Corporation
Tasks
Edit the Appserver rule
1. In Visual Studio 2005, locate the transition point method DeleteFormData.
2. In DeleteFormData, declare and instantiate two instances of the Appserver rule Deletion Relation
Item, returning DeletionRelationItem objects. The first will be for the suggestion record itself and
the second will be for the linked appointments.
3. For each object, use the method Construct(<Table Name>, <FK Field Name>), to define the
table relationships
4. Add the deletion object for the appointments to the deletion object for the suggestion by using the
method SecondaryDeletionRelationItemCollection.Add.
5. Now, declare and instantiate an instance of the Appserver rule Data Access, returning DataAccess
object.
6. Use The method CascaseDelete of the DataAccess object to delete the secondary data.
7. The final code statement should call the ASS transition point handling code.
8. Compile and save your changes
9. Restart LCS
10. Test your changes by creating a resolved suggestion and add at least one completed activity, and
then delete the suggestion.
Note: Your appendix contains a set of changes that will accomplish the desired results - use this as a
reference
Page: 87 of 128
Copyright CDC Software Corporation
Tasks
Create a new event hook script.
1. In the toolkit create a new client script; name: Suggestion_PrintForm, language VBScript
2. In the code, obtain the record id (field Suggestion_Id) from the primary recordset
3. Using a transition point parameter object set up the following user parameters
Parameter
Value
Comment
Number
1
Suggestion
This is the name of the report
Summary
2
1
The destination of the report, 1= Screen
3
4
The recordset to be used by th report, 4=
Individual Record
4
Suggestion Record Id
This is the value obtained from the primary
recordset
4. Call the method UImaster.LoadRecordComponent and pass the vntParameters array.
5. Save your changes
Note: Your appendix contains a sample of a script that will accomplish the desired results - use this script as
a reference
4. Fight click on the Print Form button and select New Event Hook->OnClick.
5. Right click the event hook and select Properties.
6. From the drop list, select the Suggestion_PrintForm client script.
Page: 88 of 128
Copyright CDC Software Corporation
Page: 89 of 128
Copyright CDC Software Corporation
Tasks
Create a New Active form
1. In the toolkit create a new active form; menu route: Active Forms->New Active Form
2. You should now be in the active form editor. A a new Anchroed Tab
3. Add the segments and fields shown below to the form
Segment
Segment Properies
Field
Field Properties
Suggestion
Type: Primary
Date
Readonly
Columns: 3
Severity
Read only
Separatr
N/A
Subject
Readonly
Colspan: 40
Comments
Assignment
Type: Primary
Columns: 1
Hide Title: Yes
Type: Primary
Columns: 3
Desription
LineCount 5
Assigned
Assigned_To
In the toolkit create a new system query; menu route: Queries->Target Queries: New
Return records from the suggestion table
Add a condition that will only returned suggestions if the boolean fields Assigned is True.
Save this query as Sys: Unassigned Suggestions.
Page: 90 of 128
Copyright CDC Software Corporation
Set permissions
11.
12.
13.
14.
Page: 91 of 128
Copyright CDC Software Corporation
Page: 92 of 128
Copyright CDC Software Corporation
Exercise 8-1
Client Script: Suggestion_OnClickFromContact
Option Explicit
OnClick_FromContact()
Sub OnClick_FromContact()
Const strfFROM_CONTACT
Const strsEmployee_Details
Const strsContact_Details
= "From_Contact"
= "Employee_Details"
= "Contact_Details"
Dim rstPrimaryRecordset
Set rstPrimaryRecordset = UIMaster.RUICenter.PrimaryRecordset
If rstPrimaryRecordset.Fields(strfFROM_CONTACT).Value = True Then
UIMaster.RUICenter.ShowSegment 0, strsContact_Details
UIMaster.RUICenter.HideSegment 0, strsEmployee_Details
Else
UIMaster.RUICenter.ShowSegment 0, strsEmployee_Details
UIMaster.RUICenter.HideSegment 0, strsContact_Details
End If
End Sub
Page: 93 of 128
Copyright CDC Software Corporation
Exercise 8-2
Form Script: Suggestion_Form
Sub OnFormLoaded(vntParameters)
DisplaySuggByDetails()
End Sub
Sub DisplaySuggByDetails()
Const strfFROM_CONTACT
Const strsEmployee_Details
Const strsContact_Details
= "From_Contact"
= "Employee_Details"
= "Contact_Details"
Dim rstPrimaryRecordset
Set rstPrimaryRecordset = UIMaster.RUICenter.PrimaryRecordset
If rstPrimaryRecordset.Fields(strfFROM_CONTACT).Value = True Then
UIMaster.RUICenter.ShowSegment 0, strsContact_Details
UIMaster.RUICenter.HideSegment 0, strsEmployee_Details
Else
UIMaster.RUICenter.ShowSegment 0, strsEmployee_Details
UIMaster.RUICenter.HideSegment 0, strsContact_Details
End If
End Sub
Page: 94 of 128
Copyright CDC Software Corporation
Exercise: 8-2
Event Hook Script: Suggestion_OnClickFromContact
Option Explicit
OnClick_FromContact()
Sub OnClick_FromContact()
Form.DisplaySuggByDetails()
End Sub
Page: 95 of 128
Copyright CDC Software Corporation
Exercise 8-3
Form Script: Suggestion_Form
Exercise 8-3
Form Script: Suggestion_Form
New Subroutine : Set Required
Sub SetRequired()
Const
Const
Const
Const
Const
Const
Const
strfASSIGNED
strfASSIGNED_TO
strfREVIEWED
strfREVIEWED_BY
strfSEVERITY
strsREVIEW
straREVIEW
=
=
=
=
=
=
=
"Assigned"
"Assigned_To"
"Reviewed"
"Reviewed_By"
"Severity"
"Review"
"Review Tab"
Dim rfrmForm
Dim rstPrimaryRecordset
With UIMaster
Set rfrmForm = .RUICenter.Form
Set rstPrimaryRecordset = .RUICenter.PrimaryRecordset
End With
If rstPrimaryRecordset.Fields(strfASSIGNED).Value = True Then
UIMaster.RUICenter.SetFieldRequired strsREVIEW, strfASSIGNED_TO, True
UIMaster.RUICenter.SetFieldRequired strsREVIEW, strfSEVERITY, True
Else
UIMaster.RUICenter.SetFieldRequiredEx straREVIEW, strsREVIEW, strfASSIGNED_TO, FALSE
UIMaster.RUICenter.SetFieldRequiredEx straREVIEW, strsREVIEW, strfSEVERITY, FALSE
End If
If rstPrimaryRecordset.Fields(strfREVIEWED).Value = True Then
UIMaster.RUICenter.SetFieldRequired strsREVIEW, strfREVIEWED_BY, True
Else
UIMaster.RUICenter.SetFieldRequiredEx straREVIEW, strsREVIEW, strfREVIEWED_BY, FALSE
End If
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
Page: 96 of 128
Copyright CDC Software Corporation
End Sub
Exercise 8-3
Form Script: Suggestion_Form
Updated Subroutine: OnFormLoaed
Option Explicit
Sub OnFormLoaded(vntParameters)
DisplaySuggByDetails()
New call to set required
SetRequired()
End Sub
Exercise 8-3
Event Hook Script: Suggestion_OnClickAssigned
Option Explicit
Form.SetRequired()
Exercise 8-3
Event Hook Script: Suggestion_OnClickReviewed
Option Explicit
Page: 97 of 128
Copyright CDC Software Corporation
Form.SetRequired()
Page: 98 of 128
Copyright CDC Software Corporation
Exercise 8-4
Form Script: Suggestion_OnClickFromContact
Option Explicit
OnClickFromContact()
Sub OnClickFromContact
Const
Const
Const
Const
Const
Const
Const
strfFROMCONTACT
strfEMPLOYEE_ID
strfCONTACT_ID
strfCOMPANY_ID
strTITLE_WARNING
strMESSAGE_EMPLOYEE
strMESSAGE_CONTACT
=
=
=
=
=
=
=
"From_Contact"
"Employee_Id"
"Contact_Id"
"Company_Id"
"Warning"
"This will clear the employee field. Continue?"
"This will clear the contact/company fields. Continue?"
Dim rfrmForm
Dim rstPrimaryRecordset
Dim intResult
With UIMaster
Set rfrmForm = .RUICenter.Form
Set rstPrimaryRecordset = .RUICenter.PrimaryRecordset
End With
If rstPrimaryRecordset.Fields(strfFROMCONTACT).Value = True Then
' Suggestion made by contact
If UIMaster.RSysClient.EqualIds(rstPrimaryRecordset.Fields(strfEMPLOYEE_ID).Value, Null) = False Then
' Employee inforamtion is filled in - check if we can clear it
intResult = Global.CMSDialog(strMESSAGE_EMPLOYEE, strTITLE_WARNING, Array("OK", "Cancel"))
If intResult = 1 Then
' OK - clear the field
rstPrimaryRecordset.Fields(strfEMPLOYEE_ID).Value = Null
Else
' Cancel - reset the 'From Contact' field
rstPrimaryRecordset.Fields(strfFROMCONTACT).Value = True
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
Page: 99 of 128
Copyright CDC Software Corporation
Exit Sub
End If
End If
Else
' Suggestion made by employee
If UIMaster.RSysClient.EqualIds(rstPrimaryRecordset.Fields(strfCONTACT_ID).Value, Null) = False Then
' Contact inforamtion is filled in - check if we can clear it
intResult = Global.CMSDialog(strMESSAGE_CONTACT, strTITLE_WARNING, Array("OK", "Cancel"))
If intResult = 1 Then
' OK - clear the fields
rstPrimaryRecordset.Fields(strfCONTACT_ID).Value = Null
rstPrimaryRecordset.Fields(strfCOMPANY_ID).Value = Null
Else
' Cancel - reset the 'From Contact' field
rstPrimaryRecordset.Fields(strfFROMCONTACT).Value = False
Exit Sub
End If
End If
End If
' Update field attributes
Form.DisplaySuggByDetails()
End Sub
Exercise 8-5
Form Script: Suggestion_From
Exercise 8-5
Form Script: Suggestion_Form
New Subroutines: NewFormData, NewSecondaryData, DeleteFormData
Exercise 8-6
Form Script: Suggestion_Form
Exercise 8-6
Form Script: Suggestion_Form
Updated Subroutine: NewFormData
Const strCMS_SYSTEM
= "CMS System"
Const strCOMPANY_ACTIVITIES = "Company Activities"
Const strfCLASSIFICATION
= "Classification"
Const strfDIALOG_TEXT
= "Please select the Suggestion Type"
Const strfDIALOG_TITLE
= "Suggestion Type"
'---------------------------------------------------------------------------------Function NewFormData(rfrmForm, vntParameters)
Dim intResult
Dim objParam
Dim rstPrimaryRecordset
Dim vntChoices
' Prompt user for type of suggestion
vntChoices = Array(strCMS_SYSTEM, strCOMPANY_ACTIVITIES)
intResult = Global.CMSDialogRadio(strfDIALOG_TEXT, strfDIALOG_TITLE, vntChoices)
if intResult <= 0 Then
UIMaster.Back 0
Else
' Add a default value in transition point parameter array
Set objParam = Global.CreateTransitPointParamsObj()
objParam.AddDefaultField strfCLASSIFICATION, vntChoices(intResult-1)
vntParameters = objParam.ConstructParams()
' Call to AppServer
NewFormData = rfrmForm.DoNewFormData(vntParameters)
End If
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
End Function
Exercise 11-1
Appserver Rule: Suggestion
//
// Exercise 11-1
// New ASR: Suggestion
//
using System;
namespace
{
using
using
using
using
using
using
CMS.EF.Server
Pivotal.Interop.ADODBLib;
Pivotal.Interop.RDALib;
Pivotal.Application.Foundation.BusinessRule;
Pivotal.Application.Foundation.Utility;
Pivotal.Application.Foundation.Data.Element;
Pivotal.Application.Foundation.Data.Element.Table;
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
public void DeleteFormData(IRForm pForm, object RecordId, ref object ParameterList)
{
try
{
pForm.DoDeleteFormData(RecordId, ref ParameterList);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
public void Execute(IRForm pForm, string MethodName, ref object ParameterList)
{
}
public object LoadFormData(IRForm pForm, object RecordId, ref object ParameterList)
{
try
{
object recordsetList = pForm.DoLoadFormData(RecordId, ref ParameterList);
return recordsetList;
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
public object NewFormData(IRForm pForm, ref object ParameterList)
{
try
{
object recordsetList = pForm.DoNewFormData(ref ParameterList);
return recordsetList;
}
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
public void NewSecondaryData(IRForm pForm, object SecondaryName, ref object ParameterList, ref Recordset
Recordset)
{
try
{
Pivotal.Interop.ADODBLib.Recordset SecondaryRecordSet = null;
pForm.DoNewSecondaryData(SecondaryName, ref ParameterList, SecondaryRecordSet);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
public void SaveFormData(IRForm pForm, object Recordsets, ref object ParameterList)
{
try
{
pForm.DoSaveFormData(Recordsets, ref ParameterList);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
public void SetSystem(RSystem pSystem)
{
try
{
m_rdaSystem = (IRSystem7)rdaSystem;
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
}
#endregion
}
}
Exercise 11-2
Appserver Rule: Suggestion
//
// Exercise 11-2
// Updated Transition Point: NewFormData
//
public object NewFormData(IRForm pForm, ref object ParameterList)
{
try
{
object recordsetList = pForm.DoNewFormData(ref ParameterList);
// Gets primary recordset
object[] recordsetArray = (object[])recordsetList;
Recordset suggestionRecordset = (Recordset)recordsetArray[0];
TransitionPointParameter transitionPointParameter = (TransitionPointParameter) m_rdaSystem
// Creates an instance the TransitionPointParamater ASR
.ServerScripts[AppServerRuleData.TransitionPointParameterAppServerRuleName].CreateInstance();
transitionPointParameter.ParameterList = ParameterList;
if (!transitionPointParameter.HasValidParameters())
transitionPointParameter.Construct();
else
// Set Default field values
transitionPointParameter.SetDefaultFields(suggestionRecordset);
return recordsetList ;
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
Challenge exercise Module 11 - make field 'Object_' required if the Classification is CMS system
Add the following code to the subroutine OnFormLodaed
Note: you will need to set up entries in the user choice list 'Object Choices'
Const strsSUGGESTION
Const strfOBJECT
= "Suggestion"
= "Object_"
Exercise 12-1
Client Script: Suggestion_OnAfterUpdateCont
Exercise: 12-1
Script: Suggesion_OnAferUpdateCont
Option Explicit
OnAfterUpdateContactId()
Sub OnAfterUpdateContactId()
Const strfCONTACT_ID = "Contact_Id"
Const strfSEVERITY
= "Severity"
Const strmGET_SEVERITY = "GetSeverity"
Dim
Dim
Dim
Dim
Dim
Dim
rfrmForm
rstPrimaryRecordset
vntParameters
objParam
vntfContact_Id
intfSeverity
End Sub
object companyId =
m_rdaSystem.Tables[ContactData.ContactTableName].Fields[ContactData.CompanyIdFieldName].Index(contactId);
// Creates an instance of a Pivotal dataset object
DataAccess rdstOpportunites = (DataAccess)
m_rdaSystem.ServerScripts[AppServerRuleData.DataAccessAppServerRuleName].CreateInstance();
rdstOpportunites.PermissionIgnored = true;
// Retunds a recordset of active opportunities for the company
Recordset rstOpportunities = rdstOpportunites.GetRecordset(strqFindActiveOpportunites, 1,
companyId, OpportunityData.OpportunityIdFieldName);
if (rstOpportunities.RecordCount > 0) userDefParameterArray[0] = 1;
break ;
}
ParameterList = transitionPointParameter.SetUserDefinedParameterArray(userDefParameterArray);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
Exercise 14-1
Appserver Rule: Suggestion
//
// Exercise 14-1 Part 1
// New local objects
//
public
public
public
public
const
const
const
const
string
string
string
string
strgSuggestions = "Suggestions";
strdSeveritySetTo = "SeveritySetTo";
strtSuggestion = "Suggestion";
strfSeverity = "Severity";
//
//
//
//
Langauge Group
Language String
Table Name
Field 'Severity'
//
// Exercise 14-1 Part 2
// Update to method 'SetSystem'
//
public void SetSystem(RSystem pSystem)
{
try
{
m_rdaSystem = (IRSystem7)pSystem ;
m_suggestionLangDict = m_rdaSystem.GetLDGroup(Suggestion.strgSuggestions);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
//
// Exercise 14-1 Part 3
// New private method SeverityMessage
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
//
private string severityMessage(int Severity)
{
string suggestionServerity =
m_rdaSystem.Tables[Suggestion.strtSuggestion].Fields[Suggestion.strfSeverity].Choices[Severity].ToString();
return m_suggestionLangDict.GetTextSub(Suggestion.strdSeveritySetTo, new
string[]{suggestionServerity}).ToString();
}
//
// Exercise 14-1 Part 4
// Updated Transition Point: Execute
//
public void Execute(IRForm pForm, string MethodName, ref object ParameterList)
{
object returnValue = DBNull.Value;
Recordset returnRecordset = null;
string outValue = string.Empty;
try
{
TransitionPointParameter transitionPointParameter = (TransitionPointParameter)m_rdaSystem
.ServerScripts[AppServerRuleData.TransitionPointParameterAppServerRuleName].CreateInstance();
transitionPointParameter.ParameterList = ParameterList;
object[] userDefParameterArray = (object[])transitionPointParameter.GetUserDefinedParameterArray();
switch (MethodName)
{
case Suggestion.GetSeverity:
object contactId ;
userDefParameterArray[0] = 0;
transitionPointParameter.InfoMessage = severityMessage(0);
transitionPointParameter.CheckUserDefinedParameterNumber(1);
contactId = transitionPointParameter.GetUserDefinedParameter(1) ;
// Get the type of contact from contact record
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
string contactType =
m_rdaSystem.Tables[ContactData.ContactTableName].Fields[ContactData.TypeFieldName].Index(contactId).ToString() ;
if (contactType == "Customer" | contactType == "Partner" )
{
userDefParameterArray[0] = 2 ;
transitionPointParameter.InfoMessage = severityMessage(2);
break;
}
// Gets the company Id from contact record
object companyId =
m_rdaSystem.Tables[ContactData.ContactTableName].Fields[ContactData.CompanyIdFieldName].Index(contactId);
// Creates an instance of a Pivotal dataset object
DataAccess rdstOpportunites = (DataAccess)
m_rdaSystem.ServerScripts[AppServerRuleData.DataAccessAppServerRuleName].CreateInstance();
rdstOpportunites.PermissionIgnored = true;
// Retunds a recordset of active opportunities for the company
Recordset rstOpportunities = rdstOpportunites.GetRecordset(strqFindActiveOpportunites, 1,
companyId, OpportunityData.OpportunityIdFieldName);
if (rstOpportunities.RecordCount > 0)
{
userDefParameterArray[0] = 1;
transitionPointParameter.InfoMessage = severityMessage(1);
}
break ;
}
ParameterList = transitionPointParameter.SetUserDefinedParameterArray(userDefParameterArray);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
}
}
Exercise: 14 Part 5
Updated Script: Suggesion_OnAferUpdateCont
New code after return from Execute
Global.CMSMsgBox objParam.GetInfoString(vntParameters), Suggestion Severity, vbOKOnly
Option Explicit
OnAfterUpdateContactId()
Sub OnAfterUpdateContactId()
Const
Const
Const
Const
Const
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
strfCONTACT_ID = "Contact_Id"
strfSEVERITY
= "Severity"
strmGET_SEVERITY = "GetSeverity"
strgSUGGESTIONS = "Suggestions"
strdSUGGESTION_SEVERITY = "Suggestion Severity"
rfrmForm
rstPrimaryRecordset
vntParameters
objParam
vntfContact_Id
intfSeverity
rldtLangDict
strMessage
objParam.SetUserDefParam 1, vntfContact_Id
vntParameters = objParam.ConstructParams
'Call Execute function
rfrmForm.Execute strmGET_SEVERITY, vntParameters
intfSeverity = objParam.GetUserDefParam (1, vntParameters)
rstPrimaryRecordset.Fields(strfSEVERITY).Value = intfSeverity
Global.CMSMsgBox objParam.GetInfoString(vntParameters), rldtLangDict.GetText(strdSUGGESTION_SEVERITY),
vbOKOnly
end if
End Sub
Exercise 15-1
Client Script: Suggestion_Form
Exercise 15-1
Form Script: Suggestion_Form
New Subroutine: NewActivity(intActivityType)
Sub NewActivity(intActivityType)
Const
Const
Const
Const
Const
Const
Const
Const
Dim
Dim
Dim
Dim
Dim
'
strrMEETING = "Meeting"
strrTO_DO = "To-Do"
strrCALL = "Call"
strrNOTE = "Note"
strfSUGGESTION_ID = "Suggestion_Id"
strfACTIVITY_TYPE = "Activity_Type"
strfCONTACT_ID = "Contact_Id"
strfCONTACT = "Contact"
strFormName
objParam
rstPrimaryRecordset
vntParameters
vntContact_Id
Exercise 15-2
Event Hook Script: Suggestion_NewCall
Form.NewActivity(2)
Exercise 15-2
Event Hook Script: Suggestion_NewMeeting
Form.NewActivity(0)
Exercise 15-2
Event Hook Script: Suggestion_NewToDo
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
Form.NewActivity(1)
Exercise 15-2
Event Hook Script: Suggestion_NewNote
Form.NewActivity(5)
Exercise 15-2
Client Script: Suggestion_Form
Exercise 15-2
Form Script: Suggestion_Form
New Subroutine: DeleteFormData
strsACTVITIES = "Activities"
strfRESOLVED = "Resolved"
strfSUGGESTION_ID = "Suggestion_Id"
strfACTIVITY_COMPLETE = "Activity_Complete"
'Call to AppServer
rfrmForm.DoDeleteFormData vntRecordId, vntParameters
End Sub
Exercise 15-3
Appserver Rule: Suggestion
//
// Exercise 15-3
// Updated Transition Point: DeleteFormData
//
public void DeleteFormData(IRForm pForm, object RecordId, ref object ParameterList)
{
try
{
// Deletion item for suggestion records
DeletionRelationItem suggestionDeleteRealtionItem =
(DeletionRelationItem)
m_rdaSystem.ServerScripts[AppServerRuleData.DeletionRelationItemAppServerRuleName].CreateInstance() ;
suggestionDeleteRealtionItem.Construct(Suggestion.strtSuggestion, Suggestion.strfSuggestionId);
// Deletion item for appointments
DeletionRelationItem appointmentsDeleteRealtionItem =
(DeletionRelationItem)
m_rdaSystem.ServerScripts[AppServerRuleData.DeletionRelationItemAppServerRuleName].CreateInstance() ;
appointmentsDeleteRealtionItem.Construct(AppointmentsData.AppointmentsTableName,
Suggestion.strfAppointmentsFKName);
// Adds appointments deletion item to collection of secondary data to be deleted
suggestionDeleteRealtionItem.SecondaryDeletionRelationItemCollection.Add(appointmentsDeleteRealtionItem);
// Provides access to cascade delete method.
DataAccess suggestionDataAccess =
(DataAccess)m_rdaSystem.ServerScripts[AppServerRuleData.DataAccessAppServerRuleName].CreateInstance();
suggestionDataAccess.CascadeDelete(RecordId, suggestionDeleteRealtionItem, false);
pForm.DoDeleteFormData(RecordId, ref ParameterList);
}
catch (Exception e)
{
throw new PivotalApplicationException(e.Message, e, m_rdaSystem);
530: Business Server Customization Fundamentals
Student International Workbook: Code Samples
}
}
Exercise 15-4
Event Hook Script: Suggestion_PrintForm
rstSuggestion
vntSuggestionId
ObjParam
vntParameters
Set rstSuggestion = UIMaster.RUICenter.PrimaryRecordset
vntSuggestionId = rstSuggestion.Fields(strfSUGGESTION_ID).Value
Set objParam = Global.CreateTransitPointParamsObj()
' Set report name
objParam.SetUserDefParam 1, strrSUGGESTION_SUMMARY
' Set Destintaition. 1 = screen, 2 = printer
objParam.SetUserDefParam 2, 1
'Set which records to use. 1 = Entire System, 2 = Static List, 3 = Query, 4 = Individual Record Selection
objParam.SetUserDefParam 3, 4
' Set record Id
objParam.SetUserDefParam 4, vntSuggestionId
vntParameters = objParam.ConstructParams()
UIMaster.LoadReportComponent(vntParameters)
End Sub
Sub
Const strfSUGGESTION_ID = "Suggestion_Id"
Dim
Dim
Dim
Dim
Dim
Dim
objParam
objrReport
strReportName
intReportDestination
intUseRecordsFrom
vntRecordSet
Set objParam = Global.CreateTransitPointParamsObj()
Exercise 15-5
Client Script: SmartPortal_Suggestion
Exercise 15-5
Client Script: SmartPortal_Suggestion
Option Explicit
Function OnClick(UIPortalItem, TableId, RecordId)
Const
Const
Const
Const
Const
Const
Dim intResult
Dim strForm
intResult = Global.CMSDialogRadio(strTITLE ,