Student Master Developers 11
Student Master Developers 11
Student Guide
Version 11
Copyright © 2015 by Aras Corporation. This material may be distributed only subject to the terms
and conditions set forth in the Open Publication License, V1.0 or later (the latest version is presently
available at http://www.opencontent.org/openpub/).
Distribution of substantively modified versions of this document is prohibited without the explicit
permission of the copyright holder.
Distribution of the work or derivative of the work in any standard (paper) book form for commercial
purposes are prohibited unless prior permission is obtained from the copyright holder.
Aras Innovator, Aras, and the Aras Corp "A" logo are registered trademarks of Aras Corporation in
the United States and other countries.
All other trademarks referenced herein are the property of their respective owners. Notice of
Liability
The information contained in this document is distributed on an "As Is" basis, without warranty of
any kind, express or implied, including, but not limited to, the implied warranties of merchantability
and fitness for a particular purpose or a warranty of non-infringement. Aras shall have no liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or
indirectly by the information contained in this document or by the software or hardware products
described herein.
MARCH 2015
Page 2
Table of Contents
Table of Contents .......................................................................................................... 3
Introduction .................................................................................................................. 5
Unit 1 Overview ..................................................................................................... 11
Unit 2 Reviewing AML ........................................................................................... 23
Unit 3 Creating a Method ...................................................................................... 61
Unit 4 Debugging Client/Server Methods ............................................................. 85
Unit 5 Creating Custom Actions............................................................................. 99
Unit 6 Exploring the Innovator Class ..................................................................... 115
Unit 7 Exploring the Item Class.............................................................................. 131
Unit 8 Creating Server Event Methods .................................................................. 159
Unit 9 Passing Event Parameters ........................................................................... 177
Unit 10 Exploring Aras Object Functions ................................................................. 197
Unit 11 Creating Client Event Methods ................................................................... 209
Unit 12 Using Federated Items/Properties.............................................................. 235
Unit 13 Integrating a .NET Application .................................................................... 253
Unit 14 Using an External Client .............................................................................. 265
Unit 15 Importing Data with Batch Loader.............................................................. 277
Unit 16 Configuring the Scheduler Service .............................................................. 295
Appendix A: Custom Search Result Sets .................................................................... 305
Appendix B: Creating Form Dialogs........................................................................... 313
Appendix C: Customizing a Form .............................................................................. 327
Appendix D: Creating a Configurable Grid ................................................................. 335
Appendix E: Tracking Login and Logout .................................................................... 359
Appendix F: Working with Relationship Grids .......................................................... 365
Lab Solutions ................................................................................................................. 383
Index .................................................................................................................... 407
Page 3
Developing Solutions
Page 4
Introduction
Overview: In this course, you will learn how to customize and extend the Aras Innovator
environment and include business logic in a solution. You will also learn how
to establish integrations with other systems using the Aras Innovator Object
Model (IOM) API and gain a working knowledge of AML (Adaptive Markup
Language).
Goals: Use AML to add, edit and remove Items from the database.
Create Client and Server Methods to modify, extend or replace standard
system behaviors.
Debug a Client or Server method using Microsoft Visual Studio
Associate Client and Server methods with system events and user actions
Explore and use the IOM methods available in the Innovator and Item
classes
Use an alternate client with the Innovator Server
Integrate Aras Innovator into a Microsoft Windows or .NET web
application
Page 5
Developing Solutions
Aras Overview
Business Next Generation Enterprise Software Solutions
Aras takes a very different approach to PLM. We combined enterprise open source solutions with
advanced model-based SOA technology to deliver a highly scalable, flexible and secure PLM solution
suite. Our extensive out-of-the-box functionality and modern Web architecture enable you to
deploy quickly and continuously enhance your PLM environment in a fraction of the time required
by conventional enterprise PLM / PDM systems and at a Total Cost of Ownership far below that of
any leading competitor.
Page 6
Introduction
Aras Customers
Aras enterprise open source solutions are for performance driven companies of all sizes from
Fortune 500 enterprises to midsized businesses looking to get an edge on the competition.
Companies achieve better customer alignment, greater profit margins, and shorter development
cycles with the Aras Innovator enterprise open source solutions.
Page 7
Developing Solutions
Course Goals
When you have completed this course you should
be able to:
▫ Query, add, delete and modify Items using AML
▫ Use the IOM to create and debug client and server
methods to replace or extend solution behaviors
▫ Work with federated properties
▫ Use an alternate client
▫ Integrate a .NET application
▫ Schedule Method execution
▫ Import data using the Batch Loader
Copyright © 2014 Aras All Rights Reserved.
Page 8
Introduction
Topics
Overview
Reviewing AML
Creating a Method
Debugging Client and Server Methods
Creating Custom Actions
Reviewing Innovator Class methods
Reviewing Item Class methods
Creating Server Methods with the IOM
Creating Client Methods with the IOM
Copyright © 2014 Aras All Rights Reserved.
Page 9
Developing Solutions
Page 10
Unit 1 Overview
Overview: In this unit you will learn about the Aras Innovator Architecture and how you
can programmatically interact with the Innovator Server. You will also review
the Aras Innovator Methodology which describes the basic rules you should
follow when developing solutions.
Page 11
Developing Solutions
System Architecture
Web Interface Other Clients
Business Logic
Configuration Services
Classification Services
BizTalk Server
Federation Services
Lifecycle Services
Security Services
Vaulting Services
Search Services
Event Services
Business Objects & Processes
XML / SOAP
ADO.NET Data Access
Database MOSS
Microsoft Office
Business Logic SharePoint Services
Files
Business Objects & Processes
SharePoint Portal Server
Object Definitions
Process Definitions
SharePoint
System Definition Files
Slide 3
Copyright © 2014 Aras All Rights Reserved. aras.com
The Client uses a set of .browser neutral controls sharing a single XML-SOAP communication port to
the server. (Currently, the Internet Explorer browser also utilizes several .NET controls.)
The Aras Innovator client is a “thin” interface - requiring the user access the Innovator Server using
either MS Internet Explorer or Mozilla Firefox.
You can also create your own client or use an alternative client which you learn about later in this
course.
Because Aras Innovator uses a SOA Architecture it can easily be incorporated into an enterprise
solution with other providers.
Page 12
Overview
Client
IOM.dll
Innovator Server
You will be interacting with the Innovator Object Model (IOM) which is a collection of classes and
methods that can generate, send and respond to requests made on the server.
The IOM can be accessed from both the client (using JavaScript) as well as the server (using C# or
VB.NET) and uses the same method calls (with a few exceptions). This makes it easy to learn the
IOM API since the calls are similar regardless of location.
Page 13
Developing Solutions
You have several ways you can interact with the Innovator Server including:
In this course, you will learn how to use all the various approaches available.
Page 14
Overview
The AML is the language that drives the Aras Innovator Server.
Page 15
Developing Solutions
Methods follow the Item Factories design pattern; they should return a new Item and not
side effect the context Item.
Server Events are the exception because the purpose is to intercept and operate on the AML
before the server parses it, and before the AML is returned to the client after the server
parses it. So you do modify the context Item and return nothing.
Implement changes/edits to the context Item in the OnBefore Event by altering the AML
before the server parses it. Refrain from attempting to update the context Item after the
server has already operated on it in the OnAfter Event. Use the OnAfter Events to
update/include federated data in the response AML.
Use the select, page, and pagesize attributes for the AML queries to optimize the
performance for the request.
Use the generic IOM methods to construct the AML queries rather than convenience
methods like getItemBy_, getRelationships(), or use the levels attribute because the
convenience methods typically return far more data than is required imposing a
performance hit.
The context Item is the keyword this Object for JavaScript, C# and the Me Object for VB.Net.
Attributes are used to pass control switches to the Method. You can invent your own and
they can be a simple way to pass additional meta-data to a Method.
Page 16
Overview
In addition to the IOM API an Innovator Client method has access to many additional JavaScript
methods that are associated with an object named “aras”. These methods have been created to
interact with the Innovator Server or provide convenience utilities while working on the client.
Page 17
Developing Solutions
An Item in Innovator is like an “Object” in Object Oriented terminology. It is used to represent real
world ‘things’.
The nature and behavior of Objects is defined in a blueprint or template, referred to as a ‘Class’ in
Object Oriented terminology. This is known as the ItemType in Innovator.
Items are related to Properties, which store data with the Item similar to properties of an Object in
OO terms.
ItemTypes have “Item Action” and “Server Event” relationships, which describe their behavior -
similar to methods defined for a Class.
Page 18
Overview
Summary
In this unit, you learned about the Aras Innovator Architecture and different ways you can interact
with the Innovator Server. You also learned the basic rules for creating new programs in the
environment.
Page 19
Developing Solutions
Lab Exercise
Goal:
Be able to describe the class business case scenario and data model to be used in this course.
Description:
This course continues with the business Items you were introduced to in the Configuring Solutions
course.
These include:
Design Requests
Change Requests
Sales Orders
Customers
In addition, the Part ItemType is now used to demonstrate Part to Part relationships in the following
hierarchy:
Page 20
Overview
You will provide custom business logic to the solution to validate consistency of data, implement
specific business rules and provide data access to external client applications.
A small set of sample data has been provided to that you can begin to access and modify business
Items. Do not change any of the sample data Items as they will be used in subsequent labs in the
course.
Page 21
Developing Solutions
Page 22
Unit 2 Reviewing AML
Overview: In this unit, you will learn how to use Adaptive Markup Language (AML) to
create custom search queries as well as how to add and modify Items in the
Innovator database. AML is the language that drives Aras Innovator and all
communication between client and server is done using the AML dialect.
Sometimes termed the “secret sauce” of Aras Innovator, understanding this
language will also help you to work effectively with the IOM classes and
methods.
Page 23
Developing Solutions
Defining AML
“Everything in Aras Innovator is an Item”
Every Item is described using Adaptive Markup
Language (AML)
AML
Client
Innovator Server
The Adaptive Markup Language (AML) is an extension to XML that allows you to perform operation
like search, edit, update and delete of Items without using the Aras Innovator user interface.
Any information that is exchanged between a client and the server is formatted in AML. So every
transaction you have performed in this course has generated AML that was sent to the Innovator
Server and then returned back to the client with results.
AML is used in integrations to other systems, for building advanced queries against the database as
well as for batch loads or updates to the database.
In this unit, you will learn the basics of AML and be able to build queries, as well as edit and delete
Items. More information about AML is also available in the Aras Innovator’s Programmer’s Guide.
Page 24
Unit 2 – Reviewing AML
AML Options
AML Allows Item:
▫ Retrieval – complex queries
▫ Additions – multi-level items
▫ Modifications
▫ Purging (of a version)
▫ Deletions
▫ Locking/Unlocking
AML provides a set of built-in operations that allow you to get, update and delete Items in the
database. You can also extend these actions with logic of your own.
Note
These built-in actions always obey the security permissions that you have defined for your solution.
Page 25
Developing Solutions
Item Item
Relationship
As we have discussed earlier, each Item you create in the database can be related to another Item
using a relationship Item.
You will recall, that a Relationship Item is created for each connection between two Items and
contains the source and related ids of the connected Items. The properties source_id and related_id
are provided for each relationship Item and store the ids of the source Item and the related Item.
This simple structure is important to remember as you begin to work with AML. Many of the AML
tags used in the language use these terms as part of the dialect.
Page 26
Unit 2 – Reviewing AML
<AML> Tag
This top level tag must always surround the encompassed Items. Like XML, a matching closing tag
(</AML>) is also required to define the document.
<Item> Tag
Contained within the AML tag are one or more Item tags that define each Item being expressed in
the AML document. Item tags also contain nested property tags that you will learn about shortly.
<Relationships> Tag
Based on our previous discussions, remember that each Item can be related to another Item using a
relationship. The Relationship tag defines the connection between the source Item (the parent tag
of this relationship) and the related Item.
Note
AML is case-sensitive. Much like XML, each tag must have a matching close tag. Unlike XML, there
is no XML schema defined for AML. Because Aras Innovator uses a self-describing data model, a
formal named workspace is not used.
Page 27
Developing Solutions
Log On Settings
AML Request
AML Response
Status Messages
Copyright © 2014 Aras All Rights Reserved. aras.com
AML Studio
To assist with creation of AML queries a tool is available for download from Aras.com on the
Community Projects page. This utility can be used to help you build queries faster and includes a
“type ahead” feature as well as a syntax check that steps you through the language as you enter an
AML request.
Log On Settings
Provide the URL to your Aras Innovator server as well as the user id, password and desired database.
After entering the URL in the field provided you can press the database lookup button to show you
the currently configured database names in the drop list. Press the Login button to connect the
server indicated. The message Login Successful will appear in the Status Message area.
AML Request
Enter a valid AML request in the field provided. Press Control + t (or choose Edit -> Tidy XML) from
the menu to check the syntax for any errors and indent the request for easier viewing. Press the
Submit Request button to send the message to the server.
You can resize the proportions between the request and response panes by dragging the scroll bar
up or down on the screen. You can also increase the size of the request text font by pressing the
Control key while moving the mouse wheel up or down.
Page 28
Unit 2 – Reviewing AML
AML Response
The AML response message from the server will appear in the AML Response pane when a message
is submitted to the server. This will either contain the requested results or an error message.
To see the response message in an alternate viewer. Click the Display Program… button and choose
an XML editor/viewer installed on your machine. When you click the Display Response button the
response text will appear using your installed viewer.
Status Messages
The message area will indicate when you are connected to the server as well as the number of items
found in a query when a search is successful.
Note
Aras Innovator also supplies a standard AML tool (NASH) when you install the Aras Innovator server.
To access this tool provide the following URL in the web browser:
http://[servername]/[InnovatorServerAlias]/Client/Scripts/Nash.aspx
The NASH tool was created by and is used by developers creating solutions for Aras Innovator. The
tool provides advanced features not available in the AML Studio. For more information see the Aras
Innovator Programmer’s Guide.
Page 29
Developing Solutions
<Item type="Part"
id=[32 character identifier]
action="get" />
type – is used to specify the ItemType of the Item. In the example above we are describing a Part
Item.
id – is used to specify which Part Item in the database we are describing. One way to locate an Item
in the database is to provide the unique identifier.
action – is used to indicate what action to take when this AML is sent to the server. Aras Innovator
has a set of built-in actions you will learn about later in the unit. You can also specify a Method that
you have written to perform some custom operation.
Note
You can obtain the id of an Item by clicking the right mouse button on an Item in search grid and
choosing the Properties menu item. The properties dialog will display the id (which can be copied).
Page 30
Unit 2 – Reviewing AML
8120-1378
In the example above, the item_number property is being used with a Part Item.
The “get” action will attempt to retrieve the Part Item with an item number of 8120-1378.
Page 31
Developing Solutions
Page 32
Unit 2 – Reviewing AML
You can group property tags into logical condition sets to locate Items that meet those conditions.
In this example, any Part Items that have a cost equal to 35 AND a weight equal to 10 AND a
make/buy equal to Make – OR – any Part Items that have a cost equal to 100 AND a weight equal to
15 AND a make/buy equal to Buy will be returned.
Note
To supply a NOT condition wrap the enclosed tags with the <not> </not> tag.
Page 33
Developing Solutions
Property Attributes
Using Conditions:
<Item type="Part" action="get">
<cost condition="gt">35</cost>
</Item>
8121-0811
Cost 55
8121-0868
Cost 70
8121-1036
Cost 36
Copyright © 2014 Aras All Rights Reserved. aras.com
Page 34
Unit 2 – Reviewing AML
between Use and keyword for range <cost condition=”between”>10 and 90</cost>
not between
in Value is in comma delimited <name condition=”in”>
set ’Admin’,’Peter’,’Bob’</name>
is null Value is null or not null <name condition=”is null” />
is not null <name condition=”is not null” />
yyyy-mm-ddThh:mm:ss
To search for Items by date and time you can use the condition property attribute to find items
before and after a specific date (and time).
Examples
<created_on condition="ge">2013-02-01</created_on>
<modified_on condition = "lt">2012-03-01T12:00:00</modified_on>
<schedule_date condition="between">2013-03-01 and 2013-04-01</schedule_date>
Page 35
Developing Solutions
Relationships Tag
“Container” for Related Items
Has no attributes
Nested ItemType Refers to the Relationship Item
<Item type="Part" action="get">
<item_number>C4723-69096</item_number>
<Relationships>
<Item type="Part BOM" action="get">
</Item>
</Relationships>
Part Part BOM
</Item> C4723-69096 (Relationship)
Describing Relationships
Items can have relationships to other Items. The Relationships tag describes a relationship between
the source Item and a related Item that has been defined with a RelationshipType. Remember that
each relationship connection is defined by a Relationship Item in the database.
In the example above, we are attempting to get a Part Item with Item Number C4723-69096 that
has a Relationship Item named Part BOM. If successful, the AML returned will describe the Part as
well as the Relationship Item.
Page 36
Unit 2 – Reviewing AML
Related Id Tag
<Item type="Part" action="get">
<item_number>C4723-69096</item_number>
<Relationships>
<Item type="Part BOM" action="get">
<related_id>
<Item type="Part" action ="get" >
</Item>
</related_id>
</Item>
</Relationships>
Part Part BOM Parts…
</Item> (Relationship)
C4723-69096
Copyright © 2014 Aras All Rights Reserved. aras.com
In this example, we are retrieving the same Part, getting the Relationship Item named Part BOM –
and from that retrieving the related Part.
Page 37
Developing Solutions
In this example, any Parts with a Part BOM relationship to a Part with the item number of
C4704-60117 will be returned.
Page 38
Unit 2 – Reviewing AML
In this example, a search is performed to find any Part BOM relationships with a related Part
number C4704-60117. If any are found, the source Part Item is also returned. Reverse lookups are
very helpful when working with Configurable Grids which will be discussed later in the course.
Page 39
Developing Solutions
Part User
(Item) (Item)
In this example, the Part Items will be searched for a property named created_by_id that can
contain an Item of type User. The search will attempt to find a User with the last_name of Admin
that is associated with this Part. If successful, the Part(s) will be returned.
Page 40
Unit 2 – Reviewing AML
Page 41
Developing Solutions
Page 42
Unit 2 – Reviewing AML
<is_released>0</is_released>
</Item>
Part C5316-60000
PC Board Kit
</AML>
Part C5316-60108
Scanner Assembly
Part C5316-60055
Power Assembly
In this example, the select attribute will retrieve the item_number and name values from the
Part Items that have not been released and then order the results by the item_number . Only 1
page with a maximum of 10 records will be returned.
Page 43
Developing Solutions
Saving Queries
1
2
3
5
6
7
Copyright © 2014 Aras All Rights Reserved. aras.com
Saving Queries
AML Queries can be saved and reused by other users who can take advantage of complex queries
only available in AML.
To Save a Query
1. Create the AML query using AML Studio and test to make sure results are correct.
2. Save the query from the Search -> Save Search… menu item.
3. Indicate if the query should be displayed on the TOC and/or shared with other users. You
can control who sees the query (described below).
To Edit a Query
1. Locate the saved search by selecting Administration -> Saved Searches from the TOC.
2. Open the search for edit. The following fields are available to further configure the saved
search:
Label
Label that appears in the TOC and MyInnovator -> Search Center page.
Itname
Itemtype of the items returned from the query.
Search Mode
The type of search to be selected in the client when the search is executed by a user. Choices
are Simple, Advanced, AML or NO UI(Hidden). For this example AML is selected.
Page 44
Unit 2 – Reviewing AML
Criteria
The AML query request.
Location
The grid associated with the query. Choices are Main, Search Dialog or Relationships.
Owned_by_id
Members of this Identity will have access to the shared saved search.
Managed_by_id
Members of this Identity are responsible for any changes to the saved search configuration.
Page 45
Developing Solutions
Page 46
Unit 2 – Reviewing AML
Page 47
Developing Solutions
Part
(Item)
In this example, a new Part will be generated with the property values specified by the property tags
above.
Page 48
Unit 2 – Reviewing AML
Page 49
Developing Solutions
<AML>
<Item type="Part" action="edit"
where="[part].item_number=
'2134-9099'">
<cost>22</cost>
</Item> Cost
22
</AML>
2134-9099
Editing an Item
Much like editing an Item in the Aras Innovator user interface, the edit action will:
1. Lock the Item specified (you must supply an Item id or use a where clause to locate the
Item).
2. Make any changes described.
3. Save the Item.
4. Unlock the Item.
In this example, a Part is being modified so that the cost value is set to 22.
Note
You should specify the table name using the bracket notation shown above to avoid "colliding" with
reserved terms in SQL Server. Remember that each ItemType is stored in its own table – the name
of the table becomes the name of the ItemType (without spaces).
Page 50
Unit 2 – Reviewing AML
In the example above, the where clause will return Assembly type Part Items and set the make/buy
to Buy.
Page 51
Developing Solutions
Using syntax we have already discussed when querying for related items, the related_id tag can be
used to assist with this operation.
In this example,
Page 52
Unit 2 – Reviewing AML
Deleting Items
<Item type="Part" action="delete"
where="[part].state='Preliminary'">
</Item>
Deleting Items
If the where clause affects more than one Item, then all Items are deleted that meet the required
criteria.
In this example, all Parts that are in the Preliminary life cycle state will be deleted.
Page 53
Developing Solutions
Page 54
Unit 2 – Reviewing AML
Page 55
Developing Solutions
Summary
In this unit you learned how to work with AML to query, add and update Items.
Page 56
Unit 2 – Reviewing AML
Review Questions
What tag is useful for working with the Item that is related to the source Item?
Page 57
Developing Solutions
Lab Exercise
Goal:
Be able to define and execute custom queries as well as add, edit and delete items using AML
commands.
Scenario:
In this exercise, you will create and build several AML queries and that become Saved Searches to be
shared with other users. You will also create several AML commands to add, edit and delete Sales
Orders in the database. Later we will use these statements to construct Method items using the
Innovator Object Model (IOM).
Retrieve Items
1. Create a new AML Search that finds all Sales Orders that allow Multiple Shipments and use the
Shipping Method of UPS. Save the Shared search that appears on the TOC with the label "Sales
Order Multiple Shipments".
2. Edit the Saved Search Item you created above so that the query finds Sales Orders that allow
Multiple Shipments OR uses the Shipping Method UPS. Note: You may need to clear client
cache to see the change – select Tools > Admin > Clear Client Metadata Cache from the main
menu.
3. Create a new AML Search that finds all Sales Orders where the associated Customer is from the
city of New York. Save as a Shared Search that appears on the TOC with the label "New York
Customers".
4. Edit the Saved Search Item you created above and restrict the query to only show New York
Customers where the Sales Order Ship Date is greater than May 1, 2013. Remember the time
format in AML is: yyyy-mm-ddThh:mm:ss.
Page 58
Unit 2 – Reviewing AML
6. Modify the command you created above so that it creates a new Sales Order and a relationship
to the Customer named Brown Industries and the Part with the item_number C4703A with a
quantity of 1.
Edit Items
7. Using AML Studio, create an AML command the will change any Sales Orders that allow Multiple
Shipments to use the UPS Shipping Method.
8. Modify the command you created above so that is also adds the Sales Order Remark "Modified
by AML Administrator" (using the comment_text property) to any orders that are changed by
this AML command. What type of relationship is Sales Order Remarks
_______________________________________?
Page 59
Developing Solutions
Page 60
Unit 3 Creating a Method
Overview: In this unit you will learn how to create a Client or Server method using the
Aras Innovator Solution Studio Editor. You will also learn about the Innovator
Object Model and the various methods available to generate AML
programmatically.
Page 61
Developing Solutions
Innovator Methods are special Items that contain source code that gets executed either on the
client or server based on which type is selected.
As mentioned earlier, the IOM is available on both the client and server and calls to the IOM
methods are basically the same.
Note
Aras Innovator Methods created in the Solution Studio Editor will be referred to as Methods (capital
“M”) in this course while class methods in the IOM will use lower case “m”.
Page 62
Unit 3 – Creating a Method
Invoking a Method
Server Method
▫ Item Actions
▫ Generic
▫ Server Events
Client Method
▫ Item Actions
▫ Generic
▫ Form, Field, Grid Events
▫ Client ItemType Events
Invoking a Method
Methods can be called in several ways depending on their purpose.
Server Methods can be called from an Action (menu driven), from another Method (Generic) or in
response to a server event (e.g. OnAdd).
Client Methods can also be called from Actions as well as other client Methods. In addition, there
are many events available in the user interface (Form, Field, Grid) that can trigger a client Method.
The ItemType also supports several events that can respond to an Item as it is displayed (e.g.
OnBeforeNew)
Page 63
Developing Solutions
Page 64
Unit 3 – Creating a Method
The On-Line Help Reference documents available classes and methods available for your use. This
includes .NET controls as well as several classes to interact with the Innovator Server.
Page 65
Developing Solutions
Contains an authenticated
connection to the server
TKT-0029-2010
MyMethod
string value = this.getProperty("priority");
Methods represent the behavior of Items. Methods execute in the context of an Item and can refer
to it using the keyword this (or Me using VB.NET).
The context Item may be a single Item, a collection of Items, an Error, just a Result (a string) or be
empty. Robust code will check for all of these possibilities.
In general, it is a best practice not to alter the context Item, to avoid side effects. An exception to
this rule is in certain Server Events where the purpose of the Method is to change the context Item.
Page 66
Unit 3 – Creating a Method
A basic rule in the Aras Innovator Methodology is that a Method should always return back an Item.
This is optional (but recommended) in client Methods. It is required for a server Method. If your
Server Method does not return an Item a compilation error will be raised when you syntax check or
attempt to run the Method.
Page 67
Developing Solutions
Creating a Method
To Create a Method
Choose Administration > Method from the TOC to create a new Method. A Method Item is created
in the database to store the source code of the procedure you will invoke from Aras Innovator.
Page 68
Unit 3 – Creating a Method
Toolbar
Code Editor
Code
Guide
Help/Debug
Method Name
Name of the Method Item to be saved in the database. Note this name is case sensitive.
Method Comments
Text description of the Method’s purpose.
Toolbar
A series of buttons for working with the editor – shown on the next page.
Code Guide
An abbreviated guide to the IOM – API Reference is more complete under Help main menu.
Help/Debug
Two tabs – Debug shows any compilation errors and Help has an abbreviated display of IOM method
parameters
Page 69
Developing Solutions
Note
Server method syntax checking is more robust as the method is compiled on the server and any
compile errors are returned as a message in the Debug window. Client syntax checking relies on the
IE browser and is not as thorough (i.e. will not check for IOM method signature errors).
Page 70
Unit 3 – Creating a Method
Running a Method
Run Client Method is an Action that has been provided for training purposes and is not available in
the standard product. Use this Action to execute a client Method and review the results. This
action uses an aras object JavaScript method that you will learn about later in this course.
Note
When a Method is executed the SAVED copy in the database is the current source of the Method.
Remember to always save the Method first before attempting to execute it.
Page 71
Developing Solutions
In the example above, an AML request is made to return back any Items of type Design Request that
have a priority Property set to “10” and response_team Property set to “Alpha”.
To create this request using the IOM you use appropriate IOM class methods to generate the AML.
In this example, a new object of type Item is created in the Method (line 1). Two properties are then
set on the object using setProperty. Finally, the object is sent to the server for process which will
return back an AML response containing any Items found.
Note
Understanding AML is key to working with the IOM effectively.
VB.NET Example
Dim itm As Item = Me.newItem("Design Request","get")
itm.setProperty("_cost", "100")
itm.setProperty("_patent_required", "1")
Return itm.apply()
Page 72
Unit 3 – Creating a Method
In this example an attribute is set in the AML request to select the id property from the Help Tickets
found. Using the select attribute can greatly reduce the amount of data that needs to be returned
from the server and can increase performance of a solution.
The setAttribute IOM method can be used to set the same attribute and generate the AML displayed
in this example.
Page 73
Developing Solutions
The Innovator and Item classes are the two main classes that contain many methods to generate
and send AML requests to the Innovator Server. You will learn about many of these methods in this
class.
Page 74
Unit 3 – Creating a Method
The IOM is intended to be a generic and compact API for modeling the Item structure of the AML as
abstract Objects. The majority of the methods for the IOM deal with memory management of the
AML document for the Item Object. The AML is a script sent as a message to the Aras Innovator
Server; the IOM is an Object API to build the AML messages, submit them to the Innovator Server
and parse an AML document that is returned by the Server.
Page 75
Developing Solutions
Server (C#)
01 Item myItem = this.newItem(" Design Request", "add");
02 myItem.setProperty("_title", "New Mobile Phone");
03 return myItem.apply();
Because everything is an Item in Aras Innovator the Item object is key to any Methods that are
created to interact with the Innovator Server.
The newItem method allows you to create an Item object in a program, set various properties and
attributes, and apply them against the Innovator Server. You will learn about more options for this
and other methods later in the course.
VB.NET
Dim myItem As Item = Me.newItem("Design Request", "add")
myItem.setProperty("_title", "New Mobile Phone")
Return myItem.apply()
Page 76
Unit 3 – Creating a Method
Server (C#)
Item myItem = this.newItem(" Design Request ", "edit");
myItem.setAttribute("where",
"[design_request]._item_number='DR-000010'");
myItem.setProperty("_cost", "250");
return myItem.apply();
As you learned in a previous unit of the course, to change an existing Item you use the edit action
which requires a “where” clause to provide the required criteria.
The Item class setAttribute method can be used to assign the where clause to the edit request, and
setProperty can be used to set the changed property value.
VB.NET
Dim myItem As Item = Me.newItem("Design Request", "edit")
myItem.setAttribute("where",
"[design_request]._item_number='DR-000010'")
myItem.setProperty("_cost", "250")
Return myItem.apply()
Page 77
Developing Solutions
Server (C#)
01 Innovator inn = this.getInnovator();
02 string myUserID = inn.getUserID();
03 return inn.newResult(myUserID);
The Innovator class provides fundamental methods for working in the IOM. You will learn about
these methods later in this course.
The Innovator object is easily obtained from the Method context Item by using the getInnovator() m
IOM ethod.
VB.NET
Dim inn As Innovator = Me.getInnovator()
Dim myUserID As String = inn.getUserID()
return inn.newResult(myUserID)
Page 78
Unit 3 – Creating a Method
Server (C#)
01 Item myItem = this.newItem("Design Request", "get");
02 myItem.setProperty("_item_number", "DR-000010");
03 myItem = myItem.apply();
04 string cost= myItem.getProperty("_cost");
05 return this.getInnovator().newResult(cost);
The newResult method takes a string as its argument which it then transforms into an Item object.
<Result>10</Result>
VB.NET
Dim myItem as Item = Me.newItem("Design Request", "get")
myItem.setProperty("_item_number", "DR-000010")
myItem = myItem.apply()
Dim cost As String = myItem.getProperty("_cost")
Return Me.getInnovator().newResult(cost)
Page 79
Developing Solutions
An Error Item will display a dialog on the client and can be configured with additional attributes you
will learn about later in this course. The example above will produce an error if the cost is set to
zero:
VB.NET
Dim inn As Innovator = Me.getInnovator()
Dim myItem As Item = Me.newItem("Design Request", "get")
myItem.setProperty("_item_number", "DR-000010")
myItem = myItem.apply()
Dim costval As String = myItem.getProperty("_cost")
If costval = "0" Then
Return inn.newError("Cost cannot be zero.")
End If
Return myItem
Page 80
Unit 3 – Creating a Method
Summary
In this unit you learned how to create new client and server Methods and some fundamental IOM
methods that are used to generate AML.
Page 81
Developing Solutions
Review Questions
What are some basic differences between client Method and a server Methods?
What IOM methods do you use to retrieve an Item(s) from the database using the IOM?
Page 82
Unit 3 – Creating a Method
Lab Exercise
Goal:
Be able to create basic client and server Methods and test them in the Innovator client.
Scenario:
In this exercise, you will create several Methods that use the IOM to generate AML to the server.
You will run these Methods using the Run Server and Run Client Method Actions available from the
Solution Studio Editor.
Retrieve Items
1. Create a Server Method named Server – GetOrders that retrieves all Sales Orders that allow
Multiple Shipments and use the Shipping Method of UPS. Unit test the Method using the Run
Server Method Action in the Method editor.
2. Create a Client Method named Client – GetOrders that performs the same command as above
but only retrieves the Sales Order number. You must use the "select" attribute to accomplish
this. What IOM method allows you to assign an attribute? ______________________________
Unit test the Method using the Run Client Method Action in the Method editor.
Add Items
3. Create a Server Method named Server – AddOrder that will create a new Sales Order with the
Shipping Method of Federal Express. Unit test in the Method editor and log on to Aras
Innovator to make sure the item is created.
4. Modify the Method you created above to also assign a Purchase Order number (using today's
date and time) using the following .NET function:
C#:
string po = DateTime.Now.ToString("yyMMddhhmmss");
VB:
Dim po As String = DateTime.Now.ToString("yyMMddhhmmss")
Edit Items
5. Create a Server Method named Server – EditOrders that will modify any Sales Orders that allow
Multiple Shipments to use the UPS Shipping Method. You must use the "where" attribute to
edit the item.
Page 83
Developing Solutions
Page 84
Unit 4 Debugging Client/Server
Methods
Overview: In this unit you will learn how to create a Client or Server method using the
Aras Innovator Solution Studio Editor. You will also learn about the Innovator
Object Model and the various methods available to generate AML
programmatically.
Page 85
Developing Solutions
Objectives
Configuring the Client Method Debugger
▫ Using Visual Studio
▫ Using Microsoft Script Debugger
Configuring the Server Method Debugger
▫ Using Visual Studio
▫ Using MS CLR Debugger (.NET SDK)
Configuring Logging
Clearing Client and Server Cache
Debugging Production Code
Inspecting AML Requests/Responses
Copyright © 2014 Aras All Rights Reserved. aras.com
Configuring a debugger for client and server Methods is probably one of the most important steps
you will take when you begin to create custom solutions (unless you are a perfect coder!).
Because Aras Innovator is a Microsoft .NET server application you can easily configure Visual Studio
or the Microsoft Script Debugger to execute at a break point in your Method.
Just-In-Time debugging is a feature that launches the Visual Studio debugger automatically when a
program, running outside Visual Studio, encounters a fatal error. Just-In-Time debugging allows you
to examine the error before the application is terminated by the operating system.
Page 86
Unit 4 – Debugging
Note
It is sometimes necessary to attach to a named process in order for the Just In Time debugger to
execute successfully.
From the Visual Studio main menu select Tools >> Attach To Process …
The .NET System.Diagnostics.Debugger.Launch() command will start the Visual Studio JIT debugger if
the debugger has not been started. To run the same Method again in the same debug session you
can use the System.Diagnostics.Debugger.Break() command.
The following code will work for first time and repeat invocations of the same Method:
if (System.Diagnostics.Debugger.Launch()) {
System.Diagnostics.Debugger.Break();
}
VB.NET
If System.Diagnostics.Debugger.Launch() Then
System.Diagnostics.Debugger.Break()
End If
Page 87
Developing Solutions
Each time a server Method is created and saved successfully, a corresponding dll assembly file as
well as a program database file (pdb) can be created containing the compiled program code for
debugging purposes.
To further assist in debugging server Methods, a “smart naming” feature is available when the
corresponding dll and pdb files are created. To activate this feature, the DebugServerMethod key
must be set to “true” as described in the previous section. In addition, the following key must be
provided in the InnovatorServerConfig.xml file:
where path is equal to a directory location to store the resulting dll and pdb files.
If both settings are provided the following corresponding files are created and named using the
following notation:
10.0.0.5846.InnovatorSolutions.SampleMethod.17FBE8EAA7DD41329FE52D6E3CEE135A.dll
10.0.0.5846.InnovatorSolutions.SampleMethod.17FBE8EAA7DD41329FE52D6E3CEE135A.pdb
IIS Settings
The Windows IIS server default the debug timeout on a single Method step to 90 seconds which
causes the client to hang when time expires. You can change this behavior by selecting the Aras
Application Pool in IIS and accessing the Advanced Setting. From the context menu set Process
Model/Ping Enabled to False (default true), or increase the Ping Maximum Response Time.
Page 88
Unit 4 – Debugging
You can use all of the Visual Studio debugging features available (single step, quick watch, etc.) while
examining your Method code.
Notes
As discussed earlier, your Method runs inside of the Aras Framework – you can view the framework
code while examining your own Method.
You can also write debug messages to the Visual Studio Output window by using the .NET Write
method of the System.Diagnostics.Debug class :
Page 89
Developing Solutions
Page 90
Unit 4 – Debugging
To debug client JavaScript methods with VS 2010 (or greater) requires additional setup. Use the
following steps to debug a client program:
1. Start Aras Innovator in Internet Explorer but do not logon to the system.
2. Start Visual Studio 2010.
3. From the VS 2010 main menu, select "Tools" and "Attach to Process"
4. Locate the "iexplore.exe" process with the "Title" that matches the Aras Innovator instance.
5. Select the process and click "Attach".
6. Return to the login screen for Aras Innovator and press F5 to refresh the page.
7. Log in to Aras Innovator
8. Run the Method and the application will switch to the "Microsoft Visual Studio .NET 2010"
debugger and break on the debugger; statement in a client JavaScript method.
Page 91
Developing Solutions
You can set and use a simple flag to indicate when you want the client debugger to be invoked. If
you choose Debug from the Tools menu property named DEBUG is set to true on the client aras
object.
Example
If the following code is placed at the top of a client Method, the debugger will be invoked if the
Debug menu is set to true (checked):
if (top.aras.DEBUG) {
Alert(“Debug is set”);
debugger;
}
Page 92
Unit 4 – Debugging
Inspecting an Item
Item contains:
▫ dom – Document Object Model for Item
▫ node – item node (if a single Item)
▫ nodelist – item nodes (if more than one Item returned)
Typically, it is useful to examine the Item in question while debugging your Method code.
Remember that Document Object Model of the Item is contained in the dom property, while the
actual Item node (or nodes) is displayed in the node or nodelist property respectively.
If a single Item is constructed (returned) from the Server, the node property points to a single
instance. If a collection is returned, the nodelist property points to this collection.
Page 93
Developing Solutions
Aras Innovator caches the Item DOM in memory along with other browser information. At times, it
may be necessary to clear this cache to resolve a problem or prevent the inspection of “stale” data.
When a client is started, Aras Innovator will cache metadata about commonly used Item types that
a user works with in a session to improve performance. You can clear this cache by selecting Clear
Client Metadata Cache from the Tools > Admin menu.
You should also delete any IE temporary files using the IE browser delete files feature.
Page 94
Unit 4 – Debugging
Configuring Logging
Writing to a log file:
▫ CCO.Utiltities.WriteDebug("logfilename", stringvar)
Appends stringvar text to log file
Log files written to "temp_folder" location
▫ Configured in InnovatorServerConfig.xml file
Example:
01 string msg = "Changed variable value";
02 CCO.Utilities.WriteDebug("DebugMsg", msg);
The CCO class (Core Context Object) contains several useful utility methods including the ability to
write debug messages to a log file. The WriteDebug method accepts two arguments – the name of
the log file (the .log extension is automatically applied) and a string which represents the log text to
append to the file. In the example above, the log file DebugMsg.log will be created (if it does not
already exist) and the message will be added to the file with a date and time stamp.
The location of the debug log is indicated by the temp_folder setting in the
InnovatorServerConfig.xml file.
Page 95
Developing Solutions
Debugging production code presents its own set of issues as it may not be possible to set
breakpoints or disturb the system as it is running.
You can:
Page 96
Unit 4 – Debugging
Summary
In this unit you learned how to configure Aras Innovator to work with a Just in TimeDebugger like
Microsoft Visual Studio to be able to debug both client and server Methods.
Page 97
Developing Solutions
Lab Exercise
Goal:
Be able to debug client and server Methods using the Visual Studio debugger.
Scenario:
In this exercise, you will debug a server Method to determine and correct a problem.
Time:
20 minutes
Steps:
1. Locate the Method named DebugMe. This server Method was created to return the current
purchase order number of a Sales Order as a Result and does not run correctly.
2. Check the Method syntax first to correct any issues before trying to run or debug the Method
and then insert the appropriate statement to start the Visual Studio Debugger and run the
Method.
3. Use Single Step (F10) to step over each statement in your Method and notice how the AML is
generated at each statement for the Item you are working with.
4. Step past the apply() method statement in the code and inspect the Item(s) returned.
5. Compare the property names used in the Method with the Sales Order ItemType properties.
Page 98
Unit 5 Creating Custom Actions
Overview: In this unit you will learn how to build Actions that appear on the client menu
to allow a user to perform an operation. You will learn about the three kinds
of Actions available and use an Action that displays a custom editable dialog in
a solution.
Page 99
Developing Solutions
Defining Actions
Action Items bind Methods to Client User Interface
Action is invoked on client and can execute:
▫ Client Method
▫ Server Method
User selects from:
▫ Action Menu Bar
▫ Mouse Popup Context Menu
Slide 3
Copyright © 2014 Aras All Rights Reserved. aras.com
An Action Item is used to bind Methods to the client user interface. Actions provide the hooks for
invoking Methods from the Action menu bar or from the right mouse context popup menu. An
Action is invoked on the client side but can call either a client or server side Method. In both cases
the context Item must be defined.
Page 100
Unit 5 – Creating Custom Actions
Generic Actions appears under the Actions main menu, ItemType and Item Actions appear under the
Tear Off window Actions menu, and Item Actions also appear on the search grid context menu
(access with right mouse button).
Page 101
Developing Solutions
Defining Actions
1
2 3
4
5
6 7
Slide 5
Copyright © 2014 Aras All Rights Reserved. aras.com
Name
Name of the Action (used for Menu Item entry text).
Type
Generic, Item, ItemType (Note: URL is not supported).
Location
Location of Method – Client or Server
Label
Used in installations that support multiple languages – discussed later in this course.
Method
Name of the Client or Server Method
Target
None – no window is displayed when Method executes
Main – Method results appear in the main workspace window frame
Window – Method results appear in a popup window – subsequent calls to the Action display
new windows.
One Window –Same as Window, except Method results are appended in the same window.
On Complete
Optional Method that executes following completion of Action main Method.
Page 102
Unit 5 – Creating Custom Actions
Body
Additional arguments to be passed to Action Method. Discussed in this unit.
Query
Override of standard AML query to define context Item for the Action Method. (Only applies
to Item Actions.)
Page 103
Developing Solutions
Slide 6
Copyright © 2014 Aras All Rights Reserved. aras.com
An Item Action operates within the context of a single Item. An Item Query is generated by default
which returns the current Item the user is working on. This can be modified in the Query field on
the Action window.
The Item Query defines the context Item that the associated Method will access when the Action is
executed. You can use the keyword "this" (JavaScript/C#) or "Me" (Visual Basic) to access the
currently selected Item.
Note
When a user selects an Item to execute an Action from the search grid, the current Item's AML
"action" attribute is set to "get". You must change the "action" attribute to "edit" to allow changes
to be made to an existing Item – and apply the changes to the server.
C# Example:
this.setAttribute("action", "edit");
this.setProperty("priority", "1");
return this.apply();
VB Example:
Me.setAttribute("action", "edit");
Me.setProperty("priority", "1");
return Me.apply();
Page 104
Unit 5 – Creating Custom Actions
Slide 7
Copyright © 2014 Aras All Rights Reserved. aras.com
If the Item is cached and is “dirty” (has been modified before Action is called) then it is considered
the context Item regardless of the Item query in the Action form, otherwise the Action query is
applied to obtain the current context Item.
If no query has been supplied in the Action form then the cache Item is considered the context Item.
If no query has been supplied and there is no Item in cache then a “temporary” Item is used to
represent the context Item with just the Item type and ID attributes supplied.
Page 105
Developing Solutions
Slide 8
Copyright © 2014 Aras All Rights Reserved. aras.com
A default query is supplied in the Action form when you choose type Item. Two different queries
are defined based on whether a client or server Method will be used with the Action.
This query is for Items with no changes (cache is not dirty) –to determine the DOM for the context
Item
If cache is dirty then changes are included in the DOM so they can be saved to server on both client
and server methods
The Query syntax is defaulted automatically but can be changed – note however it will return to
default if the Action is edited and saved again.
The Syntax is different for client vs. server to maintain backward compatibility.
Page 106
Unit 5 – Creating Custom Actions
Slide 9
Copyright © 2014 Aras All Rights Reserved. aras.com
ItemType Actions define some logic for a class of Items of the same type.
The "Actions" menu item will appear when a user selects the assigned ItemType from the TOC.
Note that the “this” keyword (Me in VB.NET) in a server event refers to the current Method that is
executing. To obtain access to a different Item requires the use of the newItem method discussed
earlier in the course.
Page 107
Developing Solutions
Slide 10
Copyright © 2014 Aras All Rights Reserved. aras.com
Page 108
Unit 5 – Creating Custom Actions
Slide 11
Copyright © 2014 Aras All Rights Reserved. aras.com
Generic Actions are used for general activities that are not associated with a specific Item or
ItemType. You defined access to the context Item in the same way as an ItemType Action.
Page 109
Developing Solutions
Slide 12
Copyright © 2014 Aras All Rights Reserved. aras.com
To pass an argument to a Method in an ItemType or Generic Action use the AML property tag to
define the argument name. The value of the argument can then be retrieved using the getProperty
method discussed earlier in this course.
Note
Arguments are used for Generic and Itemtype actions only- they are not used in Item actions. A
more complete discussion of argument passing with Generic Methods is discussed later in this
course.
VB.NET
Dim disc as String = Me.getProperty("Discount", "0");
Dim val as Decimal = System.Convert.ToDecimal(disc);
Page 110
Unit 5 – Creating Custom Actions
Summary
In this unit you learned how to build custom Actions that are available from the Innovator client to
perform custom operations or show an interactive Action dialog box.
Page 111
Developing Solutions
Lab Exercise
Goal:
Be able to create an Action that calls a Method to perform a custom user function.
Scenario:
In this exercise, you will use Server and Client Methods to create custom Actions that user can
execute.
Generic Action
1. Create a Server Method named Server-GetMachineName that will retrieve the name of your
current server. You can obtain this using the .NET instruction:
C#
VB:
Return the machine name as a new Result item. See Unit 3 to review how to return a Result
item.
Attach this method to a Generic action named Get Machine Name. Make sure the Action Target
is Window.
ItemType Action
2. Create an ItemType Action named Set Shipping Method that uses the Server-EditOrders
Method you created in an earlier exercise. Set the Action Target to None. Attach the Action to
the Sales Order ItemType.
Page 112
Unit 5 – Creating Custom Actions
Item Action
3. Create a client Method that will assign today's date to the Shipping Date of an existing selected
Sales Order. Assign the Method to an Item Action named Assign Shipping Date.
A date property is always set using a "neutral" date string and must be formatted as "yyyy-mm-
dd". Example: "2010-06-10"
The following JavaScript will obtain the date in the correct format:
Page 113
Developing Solutions
Page 114
Unit 6 Exploring the Innovator Class
Overview: In this unit you will learn how use the various methods available in the
Innovator Class. These foundation methods allow you to execute AML
requests, process SQL statements, create new Items and return a new Result
or Error.
Page 115
Developing Solutions
Base methods
applyAML
▫ Submit AML string to server and returns an Item
response
applyMethod
▫ Execute server Method
applySQL
▫ Submit SQL string to server and returns an Item
response
applyAML
Item applyAML(string AML)
VB.NET
Dim inn as Innovator = Me.getInnovator
Dim AML as String = _
"<AML><Item type='Customer' action='get'/></AML>"
Dim result as Item = inn.applyAML(AML)
applyMethod
Item applyMethod( string methodName, string body)
<name>IBM</name>";
Item res =
inn.applyMethod ("GetItem", body);
return res;
VB.NET
Dim inn as Innovator = Me.getInnovator
Dim body as String = _
"<itm_type>Customer</itm_type>" & _
"<name>IBM</name>"
Dim res as Item = _
inn.applyMethod("GetItem", body)
applySQL
Item applySQL(string SQL)
VB.NET
Dim inn As Innovator = Me.getInnovator()
Dim qry As Item = _
inn.applySQL("select login_name from innovator.[user]")
Return qry
Returns:
<Result>
<Item><login_name>admin</login_name> </Item>
<Item><login_name>root</login_name></Item>
<Item><login_name>psmith</login_name></Item>
<Item> <login_name>vadmin</login_name></Item>
</Result>
NOTE
The applySQL method is intended for execution in server Methods only. Attempting to execute SQL
that modifies data in a client Method (by a user without administrative credentials) will result in an
error.
Page 117
Developing Solutions
Item methods
Retrieve an Item Create new Item
▫ getItemById ▫ newItem
▫ getItemByKeyedName
▫ getItemInDom
Create new Error Item
▫ newError
Get a New ID
▫ getNewID Create new Result Item
▫ newResult
Get next Sequence
▫ getNextSequence
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim id as String = "02898329898912891289918299129d"
Dim myItem as Item = inn.getItemById("Customer", id)
getItemByKeyedName
Item getItemByKeyedName(string itemTypeName, string keyedName)
Page 118
Unit 6 – Innovator Class methods
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim myItem as Item = _
inn.getItemByKeyedName("Document", "Attached Document")
getItemInDom
Item getItemInDom(XmlDocument DOM)
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim myItem as Item = inn.getItemInDom(item.dom)
getNewID
string getNewId()
string id = this.getNewID();
return this.getInnovator().newResult(id);
VB.NET
Dim id as String = Me.getNewID()
return Me.getInnovator().newResult(id)
getNextSequence
string getNextSequence(string sequence_name)
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim myItem as Item = inn.getNextSequence("Design Request")
Page 119
Developing Solutions
Utility methods
getI18NSessionContext
newXMLDocument
ScalcMD5
getUserID
ScalcMD5
static string ScalcMD5(string val)
var md5_string = this.getInnovator().ScalcMD5("mypassword");
newXMLDocument
XMLDocument newXMLDocument()
XmlDocument doc = this.newXMLDocument();
getUserID()
string getUserID()
string myid = this.getInnovator().getUserId();
Page 120
Unit 6 – Innovator Class methods
Generic Methods are useful for creating reusable modules. They can accept input and return an
Item. The applyMethod method allows you to call one Method from another and pass parameters
as shown above.
The XML argument list is parsed and the arguments and values become temporary properties of the
Method being passed to a called Method. The starting Method becomes the context item in the
called Method.
This allows you to access the value of the argument properties in the called Method and use them
for processing.
The called Method then returns an Item back to the starting Method for inspection.
Page 121
Developing Solutions
Calling Method
The calling method creates a parameter string that contains two arguments named itm_type and
Itm_num(line 2). The method then calls the second Method named GetItem using the applyMethod
method.
VB.NET
Dim inn As Innovator = Me.getInnovator()
Dim body As String ="<itm_type>Design Request</itm_type>" & _
"<itm_num>DR-000010</itm_num>"
Dim res As Item = inn.applyMethod ("GetItem", body)
Return res
Called Method
The context Item (ME or this) is MyMethod (calling Method) in this example. In addition, the called
method accesses the two parameters using the getProperty method and uses them to return an
Item from the server.
VB.NET
Dim item_number As String = Me.getProperty("itm_num")
Dim item_type As String = Me.getProperty("itm_type")
Dim myItem As Item = Me.newItem(item_type, "get")
myItem.setProperty("item_number", item_number)
myItem = myItem.apply()
Return myItem
Page 122
Unit 6 – Innovator Class methods
This example shows how to create a server Method named CalculateShipDate that will return a
Sales Order with an assigned ship date that has been calculated by the Method. This method can
then be called from a client Method (next page). Note that the Method expects the parameters
named "days" and "order".
VB.NET
Dim sonum As String = Me.getProperty("order")
Dim days As String = Me.getProperty("days")
'.NET Functions
Dim daynum As Integer = Convert.ToInt16(days)
Dim [date] As DateTime = DateTime.Now.AddDays(daynum)
Dim strdate As String = [date].ToString("yyyy-MM-dd")
Page 123
Developing Solutions
A client (or server) Method can then be used to call the CalculateShipDate server Method to access
server data.
Page 124
Unit 6 – Innovator Class methods
As discussed earlier in the course – an AML statement contains an "action" attribute that instructs
the server on what operation should take place (add, edit, delete, etc.). There are a collection of
built in actions available. You can also create your own custom action by creating a server Method.
This allows you to easily extend the AML actions available to other developers or users.
Page 125
Developing Solutions
You can also pass additional parameters to a custom AML action by adding one or more attributes
that then capturing the values using the getAttribute method Item class method.
To accept the attributes displayed in the AML example above two lines of the server Method would
be changed to:
C#:
string sonum = this.getAttribute("order");
string days = this.getAttribute("days");
VB.NET
Dim sonum As String = Me.getAttribute("order")
Dim days As String = Me.getAttribute("days")
Page 126
Unit 6 – Innovator Class methods
Summary
In this unit you learned about the various IOM methods available in the Innovator class.
Page 127
Developing Solutions
Lab Exercise
Goal:
Be able use locate and use the basic IOM methods available in the Innovator class.
Scenario:
In this exercise, you will create Methods that use the IOM Innovator Class.
Steps:
1. Create a client Method that allows a user to enter an AML statement into a prompt dialog box -
using the JavaScript prompt method:
Use the applyAML Innovator class method to process the AML request and return the AML
response back to the client. Attach the Method to a Generic Client Action where the output
Target is "Window" to allow users to run the utility and view the results.
Optional:
To make the output of the Action easier to read you can apply a default XML style sheet to the
AML result variable before returning it using the following example. (Note: you will only be
able to test the Method by running it from the Generic Client Action menu you created above.
The Run Client Method action in the Method editor cannot be used to test this code.)
var ss="http://localhost/Innovator10/Client/styles/default.xsl";
return your_AMLresult.applyStylesheet(ss,"URL");
2. Create a Server Method named Server-Calculator that calculates the total cost of all Parts in the
system using a SQL statement. You can quickly get the sum of a column in a database select
statement using:
Unit test the Method using the Run Server Method Action in the Method editor. Your result
should resemble the following (the actual value may differ):
Page 128
Unit 6 – Innovator Class methods
<Item>
<value>5544.00</value>
</Item
3. Now make the program more generic by allowing someone to call your Method and pass the
column_name, table_name and SQL aggregate function name as property parameters to the
SQL statement.
First, use the getProperty Item class method to get the value of "column_name", "table_name"
and "function" and assign them to string variables.
Then create a SQL select string that uses the value of these property arguments:
C#
string SQL = "select " + function + "(" + column + ") as " +
function + " from innovator." + table;
VB.NET
Dim SQL As String = "select " & function & "(" & column & ") _
as " & function & " from innovator." & table
Attach this generic Method to an Action and supply the parameter values in the Body field of
the Action as shown below. Each tag value supplied in the Body field is passed as a property
value to the generic Method.
Server-Calculator
Create one action to SUM the Part cost and another Action to AVG the cost. Attach the Actions
to the Part ItemType.
Notice how you can create one Method that performs different operations based on the Body
expression.
4. Try calling the Server-Calculator Method as an AML request using AML Studio. You will need to
set the appropriate property tags in the AML expression to calculate a result.
Page 129
Developing Solutions
Page 130
Unit 7 Exploring the Item Class
Overview: In this unit you will learn how use the various methods available in the Item
Class. These foundation methods allow you to set and get property and
attribute values, define relationships, iterate through Item collections and test
for various Item conditions.
Page 131
Developing Solutions
Base methods
apply
▫ Submit AML request to server using Context Item and
returns new Item
loadAML
▫ Load AML into Item dom property – does not return a
new Item
clone
▫ Creates a copy of Item (with new id)
▫ Can optionally clone relationships
The apply method can accept a string argument which defines a custom AML action to run on the
item in context as it is submitted to the server. You will use this method signature later in the
course.
VB.NET
Dim resultItm as Item – Me.apply("MyCustom Action")
Page 132
Unit 7 – Item Class methods
loadAML
void loadAML(string AML)
The loadAML method sets the AML string to the item DOM but does not submit it to the server. You
must use the apply() method to submit the item after the AML is loaded.
VB.NET
Dim itm As Item = Me.newItem()
Dim AML As String = "<Item type='Customer' action='get'></Item>"
Try
itm.loadAML(AML)
Catch ex As System.Xml.XmlException
Return Me
End Try
itm = itm.apply()
Return itm
clone
Item clone( bool cloneRelationships)
If cloneRelationships is true the relationships must be fetched in the item before it is copied.
VB.NET
Dim itm as Item = Me.newItem("Customer", "get")
itm. setProperty("name", "EDA")
itm = itm.apply()
Page 133
Developing Solutions
Boolean methods
isError
isCollection
isEmpty
isLogical
isNew
isRoot
VB.NET
Dim itm As Item = Me.newItem("User", "get")
itm = itm.apply()
If itm.isError() Then sResult += "Error Item " End If
If itm.isCollection() Then sResult += "Item Collection " End If
If itm.isEmpty() Then sResult += "Empty Item "End If
If itm.isNew() Then sResult += "New Item " End If
If itm.isRoot() Then sResult += "Root Item" End If
Return Me.getInnovator().newResult(sResult)
Page 134
Unit 7 – Item Class methods
Attribute methods
getAttribute getAction
setAttribute setAction
getID removeAttribute
setID
setNewID
getType
setType
VB.NET
Dim itm as Item = Me.newItem()
itm.setType("Customer")
itm.setAction("get")
itm.setAttribute("select", "name")
itm.setProperty("name", "EDA")
itm = itm.apply()
Dim id as String = itm.getID()
Dim type as String = itm.getType()
Return _
Me.getInnovator().newResult("ID: " +id+ " - " + "Type: " + type)
Page 135
Developing Solutions
Property methods
getProperty getPropertyItem
setProperty setPropertyItem
removeProperty createPropertyItem
getPropertyAttribute setPropertyCondition
setPropertyAttribute getPropertyCondition
removeProperty
Attribute fetchDefaultProperty
Values
Copyright © 2014 Aras All Rights Reserved. aras.com
Property methods
The getProperty method offers two argument signatures:
getProperty(property_name);
getProperty(property_name, default_value);
The second argument signature allows you to specify a default value to be returned from the
method if the property is not defined in the Item.
Examples:
The value of s would be equal to "" if the details property was not provided in the current Item.
Using the default value makes it easier for testing purposes in a condition statement.
Page 136
Unit 7 – Item Class methods
setPropertyAttribute/setPropertyCondition
//Add condition greater than (in this example > 50)
itm.setPropertyCondition("_cost", "gt");
itm = itm.apply();
getPropertyAttribute
string state =
itm.getPropertyAttribute("current_state", "keyed_name");
getPropertyItem
Item customer = itm.getPropertyItem("_customer");
getProperty
string id = customer.getProperty("id", "");
fetchDefaultPropertyValues
Sets the default values of all properties on the item and returns the updated item. To overwrite
current property values set the first argument to true.
itm = itm.fetchDefaultPropertyValues(true);
VB.NET
Dim itm as Item = Me.newItem("Design Request", "get")
itm.setProperty("_cost", "50")
itm.setPropertyAttribute(“_cost”, "condition", “gt”)
itm.setPropertyAttribute("locked_by_id", "is_null", "1")
itm = itm.apply();
Page 137
Developing Solutions
File methods
checkout
attachPhysicalFile
Checkout
Innovator inn = this.getInnovator();
Item qry = inn.newItem("File", "get");
qry.setProperty("filename", "Test.txt");
Page 138
Unit 7 – Item Class methods
VB.NET
Dim inn As Innovator = Me.getInnovator()
Dim qry As Item = inn.newItem("File", "get")
qry.setProperty("filename", "Test.txt")
Checkin
var itm = this.newItem("File", "get");
itm.setProperty("filename", "Test.txt");
itm = itm.apply();
//item needs to be locked to attach file
itm = itm.lockItem();
itm.attachPhysicalFile("c:\\temp\\Test.txt");
//now save the changes to File Item which will also unlock item
itm.setAction("update");
itm = itm.apply();
return itm;
Page 139
Developing Solutions
Relationship methods
addRelationship getRelationships
createRelationship getRelatedItem
removeRelationship getRelatedItemID
createRelatedItem getParentItem
setRelatedItem
fetchRelationships
Relationship methods allow you define a Relationship as part of a query and also return
Relationships or related items.
Remember, that these methods are generating AML that will be submitted to the server for
processing.
Note
The “fetch” methods in the IOM are designed to access the database directly rather than construct
an AML request in memory prior to processing. The fetchRelationships method will access the
database directly to assign the Relationships to the current context Item. The next page
demonstrates this method.
Page 140
Unit 7 – Item Class methods
Using fetchRelationships
Retrieves current relationships from server
01 Item itm = this.newItem("Design Request", "get");
02 itm.setProperty("item_number", "DR-000010");
03 itm = itm.apply();
05 return itm;
Note
In this example the “fetch” has been done after the apply – fetch retrieves from data from the
server while the other Relationships methods work with the current DOM. In the initial apply no
relationship information will be included in the returned AML for the Design Request Item.
<Result>
<Item type="Design Request" … >
…
</Item>
<Result>
Once the fetchRelationships method is invoked, the Design Request Document Relationships will
then include the relationship information.
<Result>
<Item type="Design Request" … >
…
<Relationships>
<Item type=" Design Request Document" … />
</Relationships>
</Item>
<Result>
Page 141
Developing Solutions
VB.NET
Dim itm as Item = Me.newItem("Design Request", "get")
itm.setProperty("item_number", "DR-000010")
itm = itm.apply()
//Go to server to fetch relationships
itm.fetchRelationships("Design Request Document")
Return itm
Note
The fetchRelationships method changes the current item (and automatically does an apply to the
server). In the example above the variable itm is changed by the fetchRelationships method. This is
not true for the apply method which requires that you return an itm to inspect changes.
Page 142
Unit 7 – Item Class methods
The method above will generate the AML shown below. It is important to understand how the IOM
constructs AML requests that need to use Relationships:
<Item isNew = "1" isTemp = "1" type = "Design Request" action = "get">
<Relationships>
<Item isNew = "1" isTemp = "1" type = "Design Request Document" action = "get">
<related_id>
<Item isNew = "1" isTemp = "1" type = "Document" action = "get">
<item_number>SPEC-00001</item_number>
</Item>
</related_id>
</Item>
</Relationships>
</Item>
VB.NET
Dim itm as Item = Me.newItem("Design Request", "get")
Item relationship = Me.newItem("Design Request Document", "get")
Item relitm = Me.newItem("Document", "get")
relitm.setProperty("item_number", " SPEC-00001")
relationship.setRelatedItem(relitm)
itm.addRelationship(relationship)
itm = itm.apply()
Return itm;
Page 143
Developing Solutions
In this example, a new Document is related to the Design Request using the Design Request
Document relationship.
Can you write down what the generated AML would look like that is applied to the server?
VB.NET
Dim itm As Item = Me.newItem("Design Request", "edit")
itm.setAttribute("where",
"design_request._item_number='DR-000020'")
Dim relationship As Item =
Me.newItem("Design Request Document", "add")
Dim relitm As Item = Me.newItem("Document", "get")
relitm.setProperty("item_number", "SPEC-00001")
relationship.setRelatedItem(relitm)
itm.addRelationship(relationship)
itm = itm.apply()
Return itm
Page 144
Unit 7 – Item Class methods
This example demonstrates how to retrieve related items from a source Item.
In the example, after the “fetchRelationships” has been applied to the Design Request item the
getRelationships method will return the Relationships on the Design Request (Design Request
Document).
A for loop is then used to cycle through each Relationship and the getRelatedItem method is used to
get the current Item and assign it to rel_result.
The next page describes how to use Collection methods to process a list of Items.
VB.NET
Dim relationships As Item =
itm.getRelationships(“Design Request Document”)
Dim count As Integer = relationships.getItemCount()
Dim i As Integer
For i = 0 To count - 1
Dim doc_relationship As Item = _
reltionships.getItemByIndex(i)
Dim doc_itm As Item = _
doc_relationship.getRelatedItem()
Next i
Page 145
Developing Solutions
Collection methods
getItemCount
getItemByIndex
getItemsByXPath
appendItem
removeItem
VB.NET
Dim inn as Innovator = this.getInnovator()
Dim itm as Item = this.newItem("User", "get")
Dim results as Item = itm.apply()
Page 146
Unit 7 – Item Class methods
For i = 0 to count
Dim itm_idx as Item = results.getItemByIndex(i)
Dim id as String = itm_idx.getID()
ids_str += id + ","
Next i
Return inn.newResult(ids_str);
Using XPath
XPath can be used to search for values in the DOM and return specific data. In this example, a list of
Design Requests is requested from the server. XPath is then used to locate a specific Item and
assign it to a variable
VB.NET
Dim qry as Item = Me.newItem("Design Request", "get")
qry = qry.apply()
Item itm_find = _
qry.getItemsByXPath("//Item[item_number=' DR-000010']")
Return Me.getInnovator().newResult(itm_find.getID())
You will use XPath later in the course to set columns in a Configurable Grid. We will discuss the
basics of the language in that unit if you are not familiar with the syntax.
Append/Remove Item
Append Item can be used to build a collection in a Method. Remove Item will remove an Item from
the collection.
Page 147
Developing Solutions
VB.NET
Dim itm1 as Item = Me.newItem("Customer", "get")
itm1.setProperty("name", "IBM");
Dim itm2 as Item = Me.newItem("Customer", "get")
itm2.setProperty("name", "GHC")
itm1 = itm1.apply()
itm2 = itm2.apply()
itm1.appendItem(itm2) 'Appends Item to form collection
itm1.removeItem(itm2) 'Removes the Item from the collection
return itm1
Page 148
Unit 7 – Item Class methods
Logical methods
newOR
newAND
newNOT
removeLogical
getLogicalChildren
Logical methods allow you to create Boolean queries using AND, OR or NOT. The appropriate AML
tags are generated based on how the methods are used.
In this example, a query is built to get all Design Requests that have a status of “Start” AND patent
required = true– OR – have a status of “In Review” and a patent required of false.
VB.NET
Dim qry as Item = Me.newItem("Design Request", "get")
Page 149
Developing Solutions
To modify the request above you can access the logical children of the Design Request query and
remove the “and” logic:
VB.NET
Dim lchildren As Item = qry.getLogicalChildren()
Page 150
Unit 7 – Item Class methods
New methods
newItem
newXMLDocument
The newItem method is one of the most common Item methods used as you have seen in previous
examples. You can create an “empty” Item (no parameters), an Item of a specified type with no
action assigned (one parameter) or an Item of a specific type with the action attribute set.
VB.NET
Dim itm as Item = Me.newItem("Design Request", "delete")
The newXMLDocument method can be used to create a new DOM which can then be parsed using
standard XML .NET methods.
Page 151
Developing Solutions
Error methods
getErrorString getErrorSource
setErrorString setErrorSource
getErrorCode
setErrorCode
getErrorDetail
setErrorDetail
A series of methods are available to configure a custom error message. You must first define a new
Error object to set the appropriate attributes:
err.setErrorCode("-1");
err.setErrorDetail("My custom message");
err.setErrorSource("My program");
err.setErrorString("Custom Error Message");
return err;
VB.NET
Dim inn as Innovator = this.getInnovator()
err.setErrorCode("-1")
err.setErrorDetail("My custom message")
err.setErrorSource("My program")
err.setErrorString("Custom Error Message")
Return err
Page 152
Unit 7 – Item Class methods
Extended methods
Locking Workflow
▫ lockItem ▫ instantiateWorkflow
▫ unlockItem
▫ fetchLockStatus Email
▫ email
Lifecycle
▫ promote Item to String
▫ ToString
Extended methods
These methods are described as “extended’ as they do not fit in any other “category” described
previously.
Workflow Example
The example below shows how a workflow process can be created for a controlled item using the
instantiateWorkflow method. Here it is assumed that the Method is being invoked from the
controlled Item.
VB.NET
Dim itm as Item = this.newItem("Workflow Map", "get")
itm.setAttribute("select", "id")
itm.setProperty("name", "Design Request")
itm = itm.apply()
Dim wf_id as String = itm.getID()
Dim wf_process as Item = this.instantiateWorkflow(wf_id)
Page 153
Developing Solutions
Return Me.apply("startWorkflow")
Note
Once a workflow has been instantiated, it must be started using the action startWorkflow. To
invoke an action, use the Item apply method discussed earlier in this unit. You can also cancel a
running workflow using the cancelWorkflow or close a workflow using the closeWorkflow action.
E-mail Messages
To send an e-mail message, you must first create the message and insure that the From User and To
User identities have been specified and that all users involved have valid e-mail addresses in their
User Profiles.
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim email_msg as Item = Me.newItem("Email Message", "get")
email_msg.setProperty("name", "Service Reminder")
email_msg = email_msg.apply()
//Get admin Identity
Dim iden as Item = Me.newItem("Identity", "get")
iden.setProperty("name", "Innovator Admin")
iden = iden.apply()
Try
Dim result as Boolean = Me.email(email_msg, iden);
Catch (Exception e)
return inn.newError(e.Message);
End Try
return Me;
Page 154
Unit 7 – Item Class methods
Summary
In this unit you learned about the IOM Item class methods available to create, edit and remove
Items from the database.
Page 155
Developing Solutions
Lab Exercise
Goal:
Be able use IOM Item class methods to create and manipulate Items in a solution.
Scenario:
In this exercise, you will use Item class methods to create a Part cost calculator that can be called
from an existing Sales Order to show the total of all Part line items on an order.
TIPS
The steps for this Method follow the same pattern discussed in the "Retrieving Related Items"
example discussed in this unit. The value of quantity is stored in a property on the relationship item
(between the Sales Order and the related Part item).
1. Create a Server Method named Server-CalculateCost. This server Method will be used as an
Item Action so what does the context Item (this or Me) represent? ________________________
2. Retrieve an Innovator instance using the getInnovator IOM method and store it in a
variable named inn. You will use this instance later in the program to return a new Result item.
3. Declare the following variables that will be used to calculate cost and set them to 0:
4. Use the fetchRelationships IOM method to retrieve the "Sales Order Part" relationships
from the current Sales Order item (this).
5. Now use the getRelationships IOM method to retrieve the Relationship collection from
the current item (this) and store this information in an Item variable named
relationships.
6. Get the count of relationships using the getItemCount method and store it in count.
7. Create a for-loop to iterate through each item in relationships. (See the example shown
in Retrieving Related Items in this unit if you need help with the syntax).
Page 156
Unit 7 – Item Class methods
8. Within the for-loop, access and store the currently indexed relationships item in an Item
variable named partRel using the getItemByIndex method.
9. Get the value of the quantity property from the current partRel relationship item using
getProperty , convert the returned string to an integer and store in quantity:
10. Access the related Item from the current partRel Relationship using the getRelatedItem
method and store it in an item variable named part.
11. Get the value of the cost property from the current related part item using getProperty,
convert it to a decimal variable and store in unit_cost:
14. When the for-loop completes, convert total_cost to a string and return it using the
Innovator newResult method:
inn.newResult(totalcost.ToString())
Create Action
15. Create a new Item Action named Calculate Cost that calls the Server-CalculateCost Method and
Targets a Window. Attach the Action to the Sales Order ItemType.
Page 157
Developing Solutions
Page 158
Unit 8 Creating Server Event Methods
Overview: In this unit you will learn how to build and assign server methods to customize
and extend the standard behavior of the system. This includes Item validation,
setting Item property values as well as workflow dynamic routing and
assignment. In addition, you will learn how to capture login and logout
information using a system event.
Page 159
Developing Solutions
"OnBefore" events are typically used for validation to prevent invalid data from being saved to the
database.
"OnAfter" events can be used to extend the standard behavior and perform additional operations
once the AML response has been sent back to the client.
"On" events are used to completely replace the standard behavior and require that you create an
AML response Item that is acceptable to the client. On event Methods typically take the most work
to employ in a solution. Note that when you assign a Method to an On event that behavior is
disabled by Aras Innovator and you are responsible for replacing out the task behavior.
Page 160
Unit 8 – Creating Server Event Methods
ItemType Events
Before After Instead Of
OnBeforeAdd OnAfterAdd OnAdd
Page 161
Developing Solutions
LifeCycle Transitions
A Server Method can be used before and after a lifecycle state is changed to prevent a promotion
(Pre) or extend the behaviors (Post) of a completed promotion.
Page 162
Unit 8 – Creating Server Event Methods
Workflow Events
Workflow Activity: Workflow Path
▫ OnActivate ▫ Pre Method
▫ OnAssign ▫ Post Method
▫ OnRefuse
▫ OnDelegate
▫ OnVote
▫ OnRemind
▫ OnDue
▫ OnEscalate
▫ OnClose
Workflow Events
Workflow Events are enabled for each Workflow Activity as well as each Path.
Workflow Events are useful for performing Item validation before an Activity can proceed in a
workflow. They are also used to perform Workflow Dynamic Routing (decided which path to take at
at runtime) and Workflow Dynamic Assignments (creating Activity assignments at runtime).
Page 163
Developing Solutions
OnBeforeAdd
OnBeforeUpdate
Innovator Server
Design Request
A common use of server Methods is in Item validation to prevent invalid data from being inserted
into the database based on business rules.
The onBeforeAdd and onBeforeUpdate events are fired each time an “add”, “create”, “merge” or
“edit” action is received by the server. You can then review the data being sent to the server and
prevent acceptance by returning a new Error Item.
Page 164
Unit 8 – Creating Server Event Methods
In this example the priority and support_contract properties are assigned to variables from the
context of the current Design Request Item and then tested using a condition statement.
A new Error Item is returned if the condition is true and a dialog is displayed to the user.
This Method can then be attached to an onBeforeAdd or onBeforeUpdate method to prevent the
data from being added or saved to the database.
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim p as String = Me.getProperty("priority", "0")
Dim c as String = Me.getProperty("support_contract")
If p="1" And c="0" then
Return inn.newError("Contract customer must be P1")
End If
Return Me
Page 165
Developing Solutions
OnActivate OnRemind
OnAssign OnDue
Methods Need OnRefuse OnEscalate
Access to OnDelegate OnClose
Controlled Item OnVote
Copyright © 2014 Aras All Rights Reserved. aras.com
If you attach a Method to an Activity event the context Item is the actual Activity Item which is
typically not what you are attempting to validate.
Remember that every Workflow Process is related to a Controlled Item which typically contains the
properties to be validated.
Page 166
Unit 8 – Creating Server Event Methods
Accessing the controlled Item from a Workflow Activity requires an additional step.
An AML Action Method named Get Controlled Item is available on the Aras.com Community
Projects site that retrieves the controlled Item from a Workflow Activity. Search for the package
named Workflow Automation Examples.
You can use the Item class apply method discussed earlier in this course to run a custom action..
The apply method will pass the context of the current activity to the Get Controlled Item Method.
Once you have a handle to the controlled Item you can then proceed to validate any properties on
the that Item.
VB.NET
Dim inn as Innovator = Me.getInnovator()
Dim controlledItem as Item = _
Me.apply("Get Controlled Item")
Dim subj as String = controlledItem.getProperty("subject", "")
If subj=""
return inn.newError("Subject required")
Else
Return Me
End if
Page 167
Developing Solutions
Understanding Workflow
Definition Items
Workflow Map
Corresponding Items
Activity
Defines the Activity created on the Workflow Map.
Activity Assignment
Relationship from an Activity to an Identity.
Activity Email
Relationship from an Activity to an E-mail message.
Activity Method
Relationship from an Activity to a Server Event Method.
Activity Task
Null relationship from an Activity which defines each Task on the Activity.
Page 168
Unit 8 – Creating Server Event Methods
Activity Transitions
Relationship from the Activity to a Life Cycle Transition for promotion.
Activity Variable
Null relationship defining an Activity variable that can appear on the Workflow Completion dialog.
When you define Server Events on a Workflow Activity, you have access to the Items described
above to make additions, modifications or deletions while the workflow is in process on a controlled
item.
Two of the common techniques used in customizing a workflow are to create Assignments
dynamically on an Activity as well as change to a default process route defined on the Workflow
Map.
Page 169
Developing Solutions
Another common problem when creating a solution with Workflows is dynamically assigning a route
based on custom business logic.
Remember that when the Default Path setting is used on a path following an Automatic Activity the
workflow will follow that path regardless of any other settings.
You can use this feature to dynamically “switch” paths so that only one path becomes the Default
when the Workflow Activity becomes active.
In the example above, the workflow is originally set so that both paths following the Branch activity
are Default. If an activity is created to change the Default setting on one of the paths, then only one
path will be followed.
Note
A workflow path is represented by the ItemType "Workflow Process Path".
Page 170
Unit 8 – Creating Server Event Methods
source_id
Workflow
Process Path
Activity
Copyright © 2014 Aras All Rights Reserved. aras.com
This example shows how the Default path can be turned “off” by setting the is_default property on
the Workflow Process Path Item to false (“0”).
If you assign this Method to an Automatic Activity as discussed on the previous page you can
indicate the “direction” the workflow should take based on some business rule.
VB.NET
Dim path_name as String ="Approve"
Dim qry as Item = Me.newItem("Workflow Process Path", "get")
qry.setProperty("source_id", Me.getID())
qry.setProperty("name", path_name);
Dim path as Item = qry.apply()
path.setAction("edit")
path.setProperty("is_default", "0")
path = path.apply()
Return Me
Page 171
Developing Solutions
Activity Assignment
There may be times when the recipients of an Activity Assignment are unknown until the workflow
is in progress.
You can create a dynamic assignment on an activity that indicates who should receive the
assignment and what voting weight they should receive.
Note
Assignments are represented by the ItemType "Activity Assignment"
Page 172
Unit 8 – Creating Server Event Methods
source_id related_id
Activity
Activity Identity
Assignment
In this example, a new Activity Assignment relationship is created between the current Activity and
an existing Identity (Peter Smith).
Note how both the source and related id’s are set on the Relationship. The Relationship also stores
the voting weight of the Identity in a property named “voting weight”.
VB.NET
Dim asgn as Item= Me.newItem("Activity Assignment", "add")
asgn.setProperty("source_id", this.getID())
Dim iden as Item = Me.newItem("Identity", "get")
iden.setProperty("keyed_name", "Peter Smith")
iden = iden.apply()
asgn.setProperty("related_id",iden.getID())
asgn.setProperty("voting_weight","100")
Dim res as Item = asgn.apply()
Page 173
Developing Solutions
Summary
In this unit you learned how to apply server Methods to customize a solution.
Page 174
Unit 8 – Creating Server Event Methods
Lab Exercise
Goal:
Be able use create server Methods and associate them with various events to customize a solution.
Scenario:
In this exercise, you will create several Methods to provide custom business logic to a solution. You
will then associate each Method with the appropriate event to extend the standard behavior.
Page 175
Developing Solutions
3. When the Sales Order Reject Order Workflow Activity is activated (onActivate), the following
Remark should automatically be added to the Sales Order Remarks tab:
Create a server Method and obtain the controlled item from the workflow activity as shown in
this unit:
C#
Item order = this.apply("Get Controlled Item);
VB.Net
Dim order as Item = Me.apply("Get Controlled Item")
Use the createRelationship Item class method to add a new "Sales Order Remarks"
relationship on the order.
Set the comment_text property on the relationship item to "Sales Order Cancelled" and apply
the change to the order.
Attach the Method to the Server Event of the Reject Order activity (onActivate).
To test the behavior, create a NEW Sales Order and then go the MyInnovator > InBasket to
Reject it.
Page 176
Unit 9 Passing Event Parameters
Overview: All server Methods (only) have access to a reserved class named RequestState
to allow information to be passed between Methods when they are invoked
from an event. Server Methods are typically associated with system events
that execute before and after an interaction with the Aras Innovator server.
With this facility, you can pass information from onBefore***** to onAfter***
server events on the same (or different) Items, check for the existence of event
parameters and remove or clear parameters as necessary.
Page 177
Developing Solutions
Reviewing onBefore/onAfter
Server Events
AML onAfter********
Response Event
Innovator Server
onBefore**** Event
This collection of events execute before the AML request from the client is passed to the Innovator
server and are typically used to validate data based on custom business logic (e.g. onBeforeAdd,
onBeforeUpdate, onBeforeDelete, etc.).
onAfter**** Event
This collection of events execute after the server interaction has executed and have access to the
information returned from the Aras Innovator server (e.g. onAfterAdd, onAfterUpdate,
onAfterDelete).
on***** Event
This collection of events replaces the standard behavior defined by Aras Innovator completely. It is
the responsibility of the Method developer to create the appropriate request and format the
response.
In this unit, you will learn how to assign values to a reserved class named RequestState that is
available to store and retrieve values between Methods called from different events.
Page 178
Unit 9 - Passing Event Parameters
RequestState
Key Value
“city” Boston
“myItem” (Item)myPart
“amount” 350
Innovator Server
AML onAfter********
Response Event
The RequestState class contains an Object hash table that can be assigned key/values using a series
of class methods. A typical example is to assign one or more values in a Method associated with an
onBefore**** event. Values can then be retrieved using a server Method associated with an
onAfter**** event.
For example, when an Item is deleted it may be useful to store information about the Item before it
is removed from the database and then use that information in a later call to the server after the
Item is removed (and no longer available).
Note
The RequestState values are session-based and should be removed or cleared when they are no
longer necessary.
Page 179
Developing Solutions
In the example above, three key/value pairs have been assigned to the RequestState. The first key
named “city” is set to the string of “Boston”. The second key named “itemKey” is assigned to an
Aras Innovator Item that has been declared in the program. The third key refers to an integer value.
Notes
These examples all use a string as the key name. You can use any Object type to define the key.
An exception is thrown if you attempt to add a key and it already exists in the collection using the
Add method. Assigning a value to an assisting key directly (as in the “amount” example shown
above) overwrites the current value.
Key assignments respect the Method sort order on a configured event. If two Methods have been
assigned to the same event and both assign a value to the same key, the last Method that executes
in the sort order will replace the value (assuming it already exists).
VB.NET
RequestState.Add("city", "Boston")
RequestState.Add("itemkey", myItem)
RequestState.Add("amount", 350)
Page 180
Unit 9 - Passing Event Parameters
“city” “Boston”
“itemKey” (Item)myItem
“amount” 350
In the example above, the values set on the previous page are retrieved into their appropriate
variable types. Note the use of casting to ensure the appropriate type is returned from the
RequestState.
Note
Null (or Nothing in VB) is returned if you attempt to retrieve a key that does not exist in the
collection.
VB.NET
Dim city As String = DirectCast(RequestState("city"), String)
Dim itm As Item = DirectCast(RequestState("itemKey"), Item)
Dim total As Integer = CInt(RequestState("amount"))
Page 181
Developing Solutions
To remove each key individually you can use the Remove method and supply the appropriate key
name.
To clear all key/value pairs use the Clear method which will remove all values from the
RequestState.
VB.NET
RequestState.Remove("city")
RequestState.Clear()
Page 182
Unit 9 - Passing Event Parameters
if (RequestState.Contains(“city”)) …
if (RequestState.Count < 1) …
“city” “Boston”
“itemKey” (Item)myItem 3
“amount” 350
Use the Contains method to determine if a key exists in the collection. A true or false is returned
based on the search.
Use the Count property to determine how many key/value pairs have been assigned.
The following C# example adds a new key if it does not already exist. Otherwise the key is
reassigned:
Page 183
Developing Solutions
VB.NET
Dim key As String = "amountKey"
Dim value As String = 350
If RequestState.Contains(key) Then
RequestState(key) = value
Else
RequestState.Add(key, value)
End If
Return Nothing
Page 184
Unit 9 - Passing Event Parameters
onAfterVersion
▫ Retrieve RequestState property values
▫ Compare values and prevent versioning if certain values
have changed
RequestState.Add("docnum", doc_number);
RequestState.Add("docname", name);
return null;
VB.NET
Dim doc_number As String = Me.getProperty("item_number")
Dim name As String = Me.getProperty("name")
RequestState.Add("docnum", doc_number)
RequestState.Add("docname", name)
Return Nothing
Page 185
Developing Solutions
A second server Method is created to compare the original values of the Document with any
changes. In this example, an error is returned if the user attempts to change the name or document
number in the new version:
if (previous_number != this.getProperty("item_number") ||
previous_name != this.getProperty("name") ) {
return this.getInnovator().newError("Cannot change doc number or
name in versions");
}
RequestState.Clear();
return this;
VB.NET
Dim previous_number As String = _
DirectCast(RequestState("docnum"), String)
Dim previous_name As String = _
DirectCast(RequestState("docname"), String)
The server Methods are then configured on the Document ItemType with the appropriate server
events:
Page 186
Unit 9 - Passing Event Parameters
onAfterDelete
▫ Retrieve RequestState item after item is deleted
▫ Send e-mail with message text confirming item is
deleted (with property data)
RequestState.Add("itmKey", itm);
return this;
VB.NET
Dim itm As Item = Me.newItem(Me.[getType](), "get")
itm.setID(Me.getID())
itm.setAttribute("select", "item_number,name")
itm = itm.apply()
RequestState.Add("itmKey", itm)
Return Me
Page 187
Developing Solutions
The second Method checks to make sure the itemKey has been set and then retrieves the cached
information. An email message is then generated using the email method of the Aras IOM Item
class.
if (!RequestState.Contains("itmKey")) {
return null;
}
RequestState.Remove("itemKey");
return this;
VB.NET
If Not RequestState.Contains("itmKey") Then
Return Nothing
End If
RequestState.Remove("itemKey")
Return Me
Page 188
Unit 9 - Passing Event Parameters
Page 189
Developing Solutions
The following Method is created to obtain the Product number and cache it in the RequestState
before the Product is updated.
VB.NET
Dim part As String = Me.getProperty("item_number")
RequestState.Add("prodnum", prodnum)
Return Me
The second Method retrieves the new Model number and the current Product before the new
Model is added to the system and prefixes the Model number with the Product number:
Page 190
Unit 9 - Passing Event Parameters
VB.NET
If Not RequestState.Contains("prodnum") Then
Return Me
End If
Dim prodnumber As String = DirectCast(RequestState("prodnum"),
String)
Dim modelnum As String = Me.getProperty("item_number", "")
Me.setProperty("item_number", prodnumber & "-" & modelnum)
RequestState.Remove("prodnum")
Return Me
Page 191
Developing Solutions
Result
Page 192
Unit 9 - Passing Event Parameters
Summary
In this unit you learned how to pass parameters between server event Methods.
Page 193
Developing Solutions
Review Questions
What variable data types are supported for the key or value of a RequestState?
Page 194
Unit 9 - Passing Event Parameters
Lab Exercise
Goal:
Be able to save and restore a RequestState value using a server events.
Scenario:
A user should not be able to change the Part Type once it has been established for a Part item. You
need to add a business rule that prevents a user from versioning a Part if the Type (classification) is
changed.
Create A Server Method for the onBeforeVersion event of the Part ItemType
1. Create a Server Method named PartBeforeVersion.
2. Get the value of the classification property of the current Part item (this or Me).
3. Add a RequestState key named "part_type" with the value of the classification property.
Create A Server Method for the onAfterVersion event of the Part ItemType
5. Create a Server Method named PartAfterVersion.
6. Retrieve the value of the "part_type" from the RequestState. You will need to cast the return
values to a string. See an example of string casting in this unit.
7. Get the value of the classification property of the current Part item.
8. Use an "if" statement to determine if the previous part_type and the current classification are
equal. If they are not return an error.
Page 195
Developing Solutions
Page 196
Unit 10 Exploring Aras Object
Functions
Overview: In this unit you will learn how use the various client JavaScript methods
available in the aras Object. Every window in Aras Innovator has access to the
aras Object which contains over 200 utility functions that can be used in client
Methods.
Page 197
Developing Solutions
You access the aras Object from any JavaScript client Method using the syntax:
top.aras.functioname()
Page 198
Unit 10 - Exploring Aras Object Functions
top.aras.AlertError
Examples
top.aras.AlertSuccess("Operation Completed Successfully");
top.aras.AlertError("Operation Failed", “Fault Code 201”,
“undefined”);
The AlertSuccess method has also been designed to handle a Result Item generated by the
Innovator class newResult method. It will parse the Result Item and only display the inner element
of the Item (string) to the user.
The AlertError method supports the display of a custom message which can include a fault code and
stack trace as optional arguments.
Page 199
Developing Solutions
top.aras.prompt
Parameters:
Returns:
Examples
var result = top.aras.confirm("Are you sure?", "");
Page 200
Unit 10 - Exploring Aras Object Functions
Examples
var result=top.aras.evalMethod(“My Client Method")
Page 201
Developing Solutions
Getting Paths
getServerBaseURL
▫ Get URL of Innovator Server
getBaseURL
▫ Get URL of Innovator Client
getWorkingDir
▫ Get (and check) User's Working File Checkout Directory
Examples
Page 202
Unit 10 - Exploring Aras Object Functions
Examples
var r0 = top.aras.getLoginName();
var r1 = top.aras.getUserType();
var r2 = top.aras.isAdminUser();
var r3 = top.aras.getUserID();
var r4 = top.aras.getDatabase();
var r5 = top.aras.getIdentityList();
Page 203
Developing Solutions
Validate User
ValidateVote
▫ Validate current user’s password or e-signature
Requires MD5 encrypted string and mode (“password” or “esignature”)
Returns “pass” or “fail”
You can check a user’s password or signature in a client Method to ensure the user is valid to
proceed. The password or signature must be MD5 encrypted to perform the comparison as shown
in the example.
Page 204
Unit 10 - Exploring Aras Object Functions
applyAML(AML string)
var AML =
"<AML><Item type='User' action='get' /></AML>;
var result = top.aras.applyAML(AML)”;
newIOMInnovator
Returns an Innovator object without supplying a Context Item.
applyAML
Sends an AML request to the server and returns a string containing the result. Note that the return
is not an Item but a string variable
applyItem
Sends an AML request to the server with the <AML> wrapper tags. Returns a string containing the
result. Note that the return is not an Item but a string variable
Page 205
Developing Solutions
Summary
In this unit you learned about the various IOM methods available in the Innovator class.
Page 206
Unit 10 - Exploring Aras Object Functions
Lab Exercise
Goal:
Be able use locate and use the Aras Object Functions in a client Method.
Scenario:
In this exercise, you will create a Method that use the functions discussed in this unit.
Steps:
1. Create a client Method that displays the current user’s working directory in a confirm window.
Associate the Method with a Generic Action.
Page 207
Developing Solutions
Page 208
Unit 11 Creating Client Event Methods
Overview: In this unit you will learn how to build and user client methods to customize
and extend the standard client behavior of the system. This includes client
validation and customizing the user interface.
Page 209
Developing Solutions
You can create logic to prevent the Item from being created or alter the server response before the
user sees the form appear on the client.
Page 210
Unit 11 – Customizing Client Methods
1 2 3 4 5 7
OnBeforeNew – runs before a new Item is created and can be used to cancel a new Item
request as well prevent display of the new Item Form. This is useful for preventing new
Item creation if certain conditions have not been met.
OnNew – replaces the standard new Item behavior. A client Method must be provided that
provides custom logic to replace the standard new operation.
OnAfterNew – runs after the Item has been created. Useful for populating a new Item with
data or opening custom dialogs, etc. The new request has been processed by the server and
the context Item contains the current values that will be displayed on the form. If you
change (or add properties) to the AML response they will be displayed instead (or in
addition to the existing properties) on the form.
OnShowItem – replaces the standard logic for displaying a tear off window. A client
Method must provide the custom logic to display an appropriate window.
Page 211
Developing Solutions
if (itm.isError()) {
top.aras.AlertError("Calendar Required to Create Item");
return false;
}
return true;
In this example, a Calendar must be configured for the current year by the administrator or the Item
in question cannot be created.
The program attempts to retrieve a Calendar with the year 2014. If not found the program displays
an error and returns false. A false return will block the ability for the Aras client to create a new
Item on the server.
Page 212
Unit 11 – Customizing Client Methods
This example demonstrates modification of the context Item returned from the server (response).
In this case, we want to add more information to the Item before it processed by the user interface
so the OnAfterNew event is used with the Method above.
Note
Take care when modifying a response context Item. If you provide invalid data the response may
cause unpredictable results on the client.
Page 213
Developing Solutions
You can customize the interaction between the user and the form with a series of client events on
the form, each field of the form as well as the rows and columns of the relationship grid (tab).
Page 214
Unit 11 – Customizing Client Methods
top.instance
.reltabbar
top.relationships
top.statusbar .statusbar
You can provide custom logic by associating client Methods to elements on the form as well as the
relationship grid rows and columns.
For more information on the relationship grid and creating custom call back methods see the
appendices at the end of this student guide.
Page 215
Developing Solutions
Form and Field client event Methods are useful for populating data on a form as well as providing
cross field validation before a user attempts to save Item information to the database.
Page 216
Unit 11 – Customizing Client Methods
Many of the Form events are familiar to developers who have worked with HTML forms previously.
In addition Aras Innovator has added some additional events that you can configure for your
solution.
Page 217
Developing Solutions
Page 218
Unit 11 – Customizing Client Methods
Field Events
Each field on a form can be configured to respond to the following events:
Page 219
Developing Solutions
The following references are also useful when creating client Methods to be used with Forms:
Page 220
Unit 11 – Customizing Client Methods
Form Data
Aras Innovator represents the current Item as a DOM object that stores property values. (You can
view the cache object in the debugger by inspecting this.document.item).
As a user enters data the HTML Form captures that data in the form control. That data must also be
set in the AML cache (document.item) in order for the data to be sent to the server.
In normal operations, the cache is updated each time a user leaves a field (field loses focus). When a
user saves an Item the appropriate XML tags are defined with values to be submitted to the server.
A problem can occur however if you programmatically set the value of an Item using a Method
associated with a Form or Field event.
Both the HTML control and the Item cache must be updated to the new value so that the Form
presentation and data cache are the same. Aras provides a built in function (described) on the next
page to simply this procedure.
Page 221
Developing Solutions
this.value
Obtains data from the HTML Form (not the Item cache) and is useful in field onChange events to
obtain the changed value of the current field.
document.thisItem.getProperty
Obtains data from the Item cache (not the Form control).
document.thisItem.setProperty
Assigns data to the Item cache (not the HTML Form).
window.handleItemChange
Each Aras Innovator Form contains a predefined JavaScript window function named
handleItemChange that will set the value of a property in the cache as well as update the HTML
control programmatically. You can use this function in your form client Methods to update Form
fields and the Item cache using a single operation.
Page 222
Unit 11 – Customizing Client Methods
The Method above is then added to the onClick Field Event of the Button control:
The Method obtains the value of the cost property from the context Item. The taxed cost is then
calculated using simple JavaScript operators and assigned to the total_taxed property using the
handleItemChange function.
Page 223
Developing Solutions
producttype = this.value;
if (producttype=="TB") {
window.handleItemChange("_patent_required", "1");
}
When capturing data from a Text field or Dropdown type, you can use this.value in a field event
onChange Client Method to capture the changed value. The Aras Item cache is updated when the
Text field loses focus, so calling document.thisItem.getProperty in the onChange event will return
the original field value (from the Item cache).
Page 224
Unit 11 – Customizing Client Methods
This example shows how a Form event can be used to alter the user interface dynamically at
runtime.
The onFormPopulated event is triggered each time the Form is refreshed on the screen. In this
example the field “address_state” will be hidden if the country is not “United States”. Standard
style attributes can be set in the client Method to alter the display and characteristics of the HTML
Form dynamically.
When you create a Form in Aras Innovator you are also generating an HTML page that contains
named controls. You can access those controls to change style or visibility on the control using a
client Method with JavaScript. A standard method is provided on each Aras form named
getFieldByName which will return the DIV element representing the control (and label) on the form.
In this example, if the country property is not set to the “United States” then the address_state
(DIV) on the Form is hidden from view.
This method can then be associated with the onFormPopulated event of a Form. Note the reference
to the context Item uses the document.thisItem keyword.
To access the individual HTML field elements within a tearoff window form you can also use the
following reference:
var f = document.getElementById("MainDataForm").address_state;
f.style.visibility='hidden';
Page 225
Developing Solutions
OnSearchDialog Overview
Client Event that is triggered when a user:
▫ Presses Elipsis Button to Search for Item
OnSearchDialog Overview
The OnSearchDialog event is available to respond to the following user actions:
User presses the ellipsis […] button or F2 lookup key on a form field to display an Item
search grid.
User adds a new Pick Related relationship and the related Item search grid is displayed.
Page 226
Unit 11 – Customizing Client Methods
Search Options
Prefill Search Criteria in the Item Search Grid
Search Options
When any of the actions described on the previous page occurs you can:
Prefill the Simple Search criteria in the Item search grid – this criteria can be set to be read-
only (cannot be changed by the user).
Create a custom search result set based on business logic. The user is only able to select the
Items that are defined by the custom logic. The search criteria bar is hidden and cannot be
displayed (see Appendix for information on creating custom result sets).
Page 227
Developing Solutions
Criteria provided can be fixed so that a user is not able to change it.
In this unit, we will create a Method that requires that predefines the search criteria for 2
properties. A user must have an email address in their User record and also be managed by "Peter
Smith
Page 228
Unit 11 – Customizing Client Methods
In this example, a Method named SearchCriteria is created with code as shown above. This method
will predefine the Document search to only show Released Document Items. The user will be
unable to change the state criteria. JavaScript object attributes are case-sensitive. Make sure to
enter the attributes as shown in the example.
Page 229
Developing Solutions
2 3
In this example the _attachment property has been selected in the Change Request ItemType. The
ReleaseDocumentSearch Method is assigned to the OnSearchDialog event.
Page 230
Unit 11 – Customizing Client Methods
Summary
In this unit you learned how to apply client Methods to customize a solution.
Page 231
Developing Solutions
Lab Exercise
Goal:
Be able create and use client Methods with the appropriate client events to customize a solution
that uses the Aras Innovator client.
Scenario:
In this exercise, you will create several client Methods to extend the behavior of the Innovator
client. You will then associate these Methods with appropriate client events to provide custom
business logic in a solution.
A date property is always set using a "neutral" date string and must be formatted as "yyyy-mm-
dd". Example: "2010-06-10"
You can use the JavaScript Date() function to create a new Date object as shown below:
The date should be prefilled on the client before the form is loaded. Which ItemType client
event allows you to change the Context Item of a new Item after it has been returned from the
server -but before the user sees the form? ____________________. Remember to return the
modified context Item to the client in your Method.
Use the getProperty method to get the value of the multiple_shipment property on
the current item. What syntax allows you to access the context Item on a Form or Field event?
_________________________________________________
Page 232
Unit 11 – Customizing Client Methods
If multiple_shipment is checked (true) then use a function described in this unit to change
the shipping_method property value to "UPS". Otherwise set it to "Federal Express".
Create a client Method that creates a filter object to set the classification property to
"Product". The user should not be able to change this value.
Edit the "Sales Order Part" relationship ItemType and attach this Method to the
onSearchDialog event of the related_id property.
Page 233
Developing Solutions
Page 234
Unit 12 Using Federated
Items/Properties
Overview: In this unit you will learn how to use and store data in an external resource
while still presenting the information to the user in the standard client user
interface. Federation allows you to integrate an Aras Innovator solution with
data that does not reside in the Innovator database.
Page 235
Developing Solutions
Federated Items and Properties are useful for allowing integration of data from other systems to be
incorporated into a solution.
When you mark an ItemType as Federated you are indicating that at least one property of the Item
will not be stored in the Innovator database. Remember that each ItemType that is created in Aras
Innovator represents a table in the database and each property represents a column.
With federation, you can seamlessly display and edit data and decide when and where that data
should be retrieved or stored.
Page 236
Unit 12 – Using Federated Items and Properties
Federated Options
Mixed System
▫ Some of the data is stored in a remote system
▫ ItemType is Federated
▫ Certain properties are marked as Federated
▫ Federated properties do not have a column in the
ItemType database table
Separate System
▫ All data is stored in a remote system
▫ ItemType is Federated
▫ All properties of the ItemType are Federated
▫ No data rows are created in the ItemType database
table
You have two options when designing federation into a solution. Should some of the data reside in
the Innovator database, or should all of the data be located in an outside resource.
In the “separate system” option no rows are created in the Innovator database and all data
population must be accomplished with custom logic.
In a “mixed” environment some basic data may be stored in the system (e.g. Item ID , created_on,
created_by) and data which currently resides in an outside resource can be retrieved (and updated)
but not saved to the Innovator database.
Page 237
Developing Solutions
In this unit, we will discuss and use an external Microsoft Access database to retrieve and update
data, however you can use any resource accessible through a .NET program.
Page 238
Unit 12 – Using Federated Items and Properties
To support federation, you respond to a set of server events on the ItemType. These events allow
you intercept the AML messages being passed to and from the Innovator Server to create, retrieve,
update and delete external data.
Page 239
Developing Solutions
If no data is required to be stored in the Innovator database you are required to replace the current
retrieve/update logic with your own. These events completely replace the add, edit, get and delete
standard behavior in Innovator. You are responsible for creating appropriate AML messages to and
from the server.
Page 240
Unit 12 – Using Federated Items and Properties
Federated Example
Customer -> Contact Database
CustomerPhone 212-555-1212
CustomerFax 212-555-1111
Customer Example
The standard solution database contains an ItemType named Customer that stores information
about each customer including contact data. In this example, the customer contact information will
be stored and retreived from a federated Microsoft Access database. This could be an existing
database with legacy data or a database that is used by other applications and shared by Aras
Innovator.
The Customer ItemType will become a "mixed" Federated Item with the following data stored in an
Microsoft Access Contact Database. The CustomerID will use the Aras Innovator Item id property to
maintain a link between databases.
The table Contact in the Microsoft Access Database has been defined as:
Page 241
Developing Solutions
Note
Selecting this option has no affect on system behavior but is simply used as a “marker” or reminder
that some or all of the data for this Item will be stored in a remote location. Associating Methods
with the server events discussed on the previous pages dictates if an item or property is federated.
Page 242
Unit 12 – Using Federated Items and Properties
Choosing this option will remove the database column for this property from the Customer
ItemType table in the Innovator database.
In this example, the contact_name, main_phone and main_fax numbers will no longer be stored in
the Aras database.
Page 243
Developing Solutions
<ReferencedAssemblies> - lists the DLL library files available to every Aras Method.
<Support> - lists the supported language templates. These should not be modified.
<Template> - defines each language template noted in the <Support> tags.
Note that any changes you make to the method-config.xml file are used immediately by the server
(does not require a restart). You should always keep a backup of the original config file should it be
necessary to restore back to the original configuration. The examples presented in this unit use the
System.Data.OleDb namespace from System.Data.dll already installed on the server. To make the
Aras Methods easier to read in this unit you can add the following using (or Imports) statement to
the C# (or VB) templates:
or
Page 244
Unit 12 – Using Federated Items and Properties
conn.Open();
idx_itm.setProperty("contact_name", reader["CustomerContact"].ToString() );
idx_itm.setProperty("main_phone", reader["CustomerPhone"].ToString() );
idx_itm.setProperty("main_fax", reader["CustomerFax"].ToString() );
return this;
Note that retrieving data may return more than one database row so your Method code should
expect and handle this situation. Remember that federated property data can appear in
relationship grids and the main search grids.
In this example, the Customer Item is being populated with external data from a Microsoft Access
Contact database. The setProperty method is used to set the appropriate values based on data
retrieved from the external database table.
VB.NET
Dim conn As New OleDbConnection(_
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AccessDB\Training.mdb")
conn.Open()
Page 245
Developing Solutions
idx_itm.setProperty("contact_name", reader("CustomerContact").ToString())
idx_itm.setProperty("main_phone", reader("CustomerPhone").ToString())
idx_itm.setProperty("main_fax", reader("CustomerFax").ToString())
End If
Next
conn.Close()
Return Me
Page 246
Unit 12 – Using Federated Items and Properties
conn.Open();
string id = this.getID();
string insertsql =
conn.Close();
return this;
In this example a new Contact row will be created in the external database using a sql insert
statement. The .NET String.Format method is used to provide substitution of values obtained from
Innovator to be included in the sql insert statement.
VB.NET
Dim conn As New OleDbConnection(_
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AccessDB\Training.mdb")
conn.Open()
conn.Close()
Return Me
Page 247
Developing Solutions
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\AccessDB\\Training.mdb");
conn.Open();
string id = this.getID();
string updatesql =
where CustomerID='{3}'";
conn.Close();
return this;
VB.NET
Dim conn As New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AccessDB\Training.mdb")
conn.Open()
conn.Close()
Return Me
Page 248
Unit 12 – Using Federated Items and Properties
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\AccessDB\\Training.mdb");
conn.Open();
string id = this.getID();
conn.Close();
return this;
VB.NET
Dim conn As New OleDbConnection( _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\AccessDB\Training.mdb")
conn.Open()
conn.Close()
Return Me
Page 249
Developing Solutions
Summary
In this unit you learned how to use Federated Items and Properties to integrate data external to the
Innovator database.
Page 250
Unit 12 – Using Federated Items and Properties
Lab Exercise
Goal:
Purchase Order data for each Sales Order needs to be maintained in a separate database. The
following table has been established in the Microsoft Access Training database:
You must add (or update) this table with the data entered by the user on the Sales Order. Use the
following Sales Order properties to map the data to this table:
Steps
1. Make a copy of the 3 Methods provided in your student database to federate a Customer
property (TRN_AddFedereratedData, TRN_UpdateFederatedData, TRN_GetFederatedData) .
These are the examples shown in this unit.
2. Adjust the Methods to use the Microsoft Access Columns and Aras properties described in the
table above.
3. Attach each Method to an appropriate Server Event on the Sales Order ItemType.
4. Create a new Sales Order and test the configuration. Why will these Methods only work for new
Sales Orders? ___________________________________________________________________
Federate Properties
5. Once the Methods are running successfully, you can return to the Sales Order ItemType and set
the datatype of the shipping_method and po_number properties to Federated. What happens
to any existing data in the Aras database? ___________________________________________
Page 251
Developing Solutions
Page 252
Unit 13 Integrating a .NET Application
Overview: In this unit you will learn how to install and reference the IOM in a .NET
application to provide Innovator services to an outside application. As an
alternative, you can also send standard SOAP message requests to Innovator
Server and process the responses.
Page 253
Developing Solutions
So far in this course we have focused on using the Aras Innovator standard client as a way for an end
user to gain access to the system.
In this unit, we look at alternate ways to interact with the Innovator Server by creating an ASP.NET
application that uses the IOM to interact with the system.
In this example, we will use Visual Studio 2010 to create a simple ASP .NET web application that will
interact with the Innovator Server.
Page 254
Unit 13 – Integrating a .NET Application
The IOM SDK has been created for use in developing external applications that connect to Aras
Innovator. This SDK specifically contains .NET, COM, and Windows RT compatible DLLs, to support all
3 types of connections. (Aras Version 10 SP3 and above).
Previously, application developers would copy the IOM file form the Aras Innovator code tree when
developing applications. The new SDK DLLs eliminate the process of copying the IOM from the Aras
server code tree so that Aras can remove all external dependencies from the IOM DLLs.
1. In an open Visual Studio project select Project > Add Reference… from the main menu.
2. Choose the Browse tab and select the IOM.dll from the appropriate IOM SDK directory (this
example uses .NET) .
3. Finally, add the namespace Aras.IOM to your project code to gain access to the IOM classes
and methods.
Page 255
Developing Solutions
Establishing Connection
Define the login credentials
▫ User Id, Password, Database, Server URL
Establish a server connection
▫ Using the IomFactory class
Login to the server using the connection
▫ Using the HttpServerConnection class
Create Innovator instance
▫ Using the IomFactory class
This example shows a small project that will make a connection to the student development server.
The Visual Studio ASP.Net project uses the Global.asax page to define global settings initialized
when the session begins. This example uses that page to define the Innovator variable that will be
available to any page in the application.
C#:
public class Global : System.Web.HttpApplication
{
public static Innovator inn = null;
private HttpServerConnection conn = null;
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
//Define credentials
string url = "http://localhost/Innovator10";
string db = "DevelopingSolutions100";
string user = "admin";
string pw = "innovator";
VB:
Public Class Global_asax
Inherits System.Web.HttpApplication
Public Shared inn As Innovator = Nothing
Private conn As HttpServerConnection = Nothing
Page 257
Developing Solutions
The IOM.dll assembly contains all of the Item and Innovator class methods we have used in the
course.
Once a reference to the Innovator object is established in your program code, you can begin to
access and modify Aras Innovator Items.
In addition, Visual Studio "Intellisense" make coding easier as valid options are presented as you
create your project code.
Page 258
Unit 13 – Integrating a .NET Application
Application Example
TextBox1
TextBox2
TextBox3
TextBox4
DropDownList1
CheckBox1
TextBox5
Copyright © 2014 Aras All Rights Reserved. aras.com
Application Example
The following code is placed on the ASP.Net page displayed above using the ASP.Net Button1 click
method to retrieve the details of a Sales Order by the so_number property:
C#:
protected void Button1_Click(object sender, EventArgs e)
{
Item so = Global.inn.newItem("Sales Order", "get");
so.setProperty("so_number", TextBox1.Text);
so = so.apply();
if (so.isError())
{
StatusMessage.Text = so.getErrorString();
return;
}
TextBox2.Text = so.getProperty("state", "");
TextBox3.Text = so.getProperty("po_number", "");
DropDownList1.Text = so.getProperty("shipping_method", "");
TextBox4.Text =
so.getPropertyAttribute("managed_by_id", "keyed_name");
string ms = so.getProperty("multiple_shipment");
CheckBox1.Checked =(ms == "1" ) ? true : false;
}
Page 259
Developing Solutions
VB:
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Dim so As Item = [Global_asax].inn.newItem("Sales Order",_
"get")
so.setProperty("so_number", TextBox1.Text)
so = so.apply()
If so.isError() Then
StatusMessage.Text = so.getErrorString()
Return
End If
TextBox2.Text = so.getProperty("state", "")
TextBox3.Text = so.getProperty("po_number", "")
DropDownList1.Text = so.getProperty("shipping_method", "")
TextBox4.Text = so.getPropertyAttribute("managed_by_id", _
"keyed_name")
Dim ms As String = so.getProperty("multiple_shipment")
CheckBox1.Checked = If((ms = "1"), True, False)
End Sub
The method above uses the Innovator instance variable (inn) established in the Global.asax page on
the previous page.
You can use the IOM apply method to execute this program and return a result to the solution:
VB
Dim costItm As Item = so.apply("Server_CalculateCost")
Dim totalcost As String = costItm.getResult()
TextBox5.Text = totalcost
Page 260
Unit 13 – Integrating a .NET Application
An alternative to using the IOM is to create appropriate SOAP requests that are sent to the
Innovator server. You can then process the response requests and decide how to apply the data in
your custom application client.
See the Aras Innovator Programmer’s Guide for examples of creating a properly formatted SOAP
request.
Page 261
Developing Solutions
Summary
In this unit you learned how to integrate a .NET ASP application with the Innovator server using the
IOM or sending SOAP messages.
Page 262
Unit 13 – Integrating a .NET Application
Lab Exercise
Goal:
Integrate an ASP.NET application with Aras Innovator.
Scenario:
Build an ASP.NET application that allows a user to perform basic maintenance on a Sales Order. The
application should be able to find, edit and delete Sales Orders using IOM methods you have used in
the course.
1. Open the ASP.NET project named SalesOrderApplication in the Visual Studio Projects folder.
2. Provide the logic for the Edit and Delete buttons to allow a user to modify an existing Sales
Order item. What attribute must you set to allow an edit or delete to an Item? ______________
Page 263
Developing Solutions
Page 264
Unit 14 Using an External Client
Overview: In this unit you will learn how use an external COM client (Microsoft Excel) to
access the services of the Innovator Server. You will populate and allow
editing of a spreadsheet by creating a VBA macro that uses the IOM.
Page 265
Developing Solutions
The client IOM.dll can be used with alternate clients that support the Common Object Model (COM)
interface. You are required to create a Type library file and register it which is explained in this unit.
The COM version of the IOM library is available in the IOM SDK packaged separately from the Aras
Innovator server.
Note
Prior to Aras Version 10 SP3 the COM version of the IOM.dll was available in the Aras server code
tree in the Innovator/Client/cbin directory.
Page 266
Unit 14 – Using an External Client
Use the regAsm.exe (assembly registration) program provided by the Microsoft .NET framework to
define and register the required Type library. This registration process must be performed on any
client that will access the COM IOM SDK.
Example Results:
Page 267
Developing Solutions
To Configure MS Excel
In this example, we will use the MS Excel application as an alternate COM client to the Innovator
server.
Page 268
Unit 14 – Using an External Client
This example will demonstrate retrieving and editing Design request Items from MS Excel.
Page 269
Developing Solutions
Here the credentials are hard coded into VBA variables but they could be obtained easily from a VBA
Form as well.
Page 270
Unit 14 – Using an External Client
As we learned previously, the HttpServerConnection class allows you to log on to Innovator server
using the appropriate credentials.
Note
It is a good practice to use the Logout method once the Excel session has ended to terminate the
connection to the server.
Page 271
Developing Solutions
Retrieving Data
Set innov = f.CreateInnovator(conn)
Dim qry1 As Item
Set qry1 = innov.newItem("Help Ticket", "get")
qry1.setAttribute "order_by", "item_number"
Dim res1 As Item
Set res1 = qry1.Apply
For i = 1 To res1.getItemCount
Cells(i+1,1) =
res1.getItemByIndex(i-1).getProperty("item_number")
Cells(i+1,2) =
res1.getItemByIndex(i-1).getProperty("details")
Next i
The CreateInnovator method is then used to establish an Innovator object in the program which
then allows us to work with any of the IOM methods we have discussed in this course.
In this example, all of the Design requests will be retrieved from the Innovator database, sorted by
item_number.
A for loop is then used to work with each Item individually and assign appropriate data to the MS
Excel cells (using the VBA Cells method).
Page 272
Unit 14 – Using an External Client
Saving Data
'Connection has been established to server…
active_row = ActiveCell.Row
item_number = Cells(active_row, 1)
This example gets the active row of the MS Excel spreadsheet and edits the item number based on
the contents of column 2 in the active row.
Page 273
Developing Solutions
Summary
In this unit you learned how to use an alternate COM client to communicate with the Innovator
server.
Page 274
Unit 14 – Using an External Client
Lab Exercise
Goal:
Use the Common Object Model (COM) interface to Aras Innovator with an external client.
Scenario:
In this exercise you will use Microsoft Excel to display the current Sales Orders in the Aras Innovator
database.
1. Register the client IOM.dll as a Microsoft Type Library (.tlb) using the steps outlined in this unit.
4. Add the IOM.tlb type library to the workbook from the Tools > References menu.
Defining Credentials
Creating an HttpServerConnection
Logging into the Server
Creating an Innovator instance variable
6. Use IOM API methods to retrieve all of the Sales Order items into an Item variable.
Page 275
Developing Solutions
7. Loop through the list and show the so_number, po_number and shipping_method as rows in
the Excel spreadsheet.
Page 276
Unit 15 Importing Data with Batch
Loader
Overview: In this unit you will learn how to use the Batch Loader utility to migrate data
from an outside resource into the Innovator database The Batch Loader is a
subscriber only feature available on the Aras Innovator CD.
Page 277
Developing Solutions
The Aras Batch Loader tool is a utility for loading data from a flat file into Aras Innovator. This tool
transforms the flat file data into AML for loading directly into Aras Innovator much like an
alternative client.
The Batch Loader has two distinct modes for loading data. The first, more direct method is through
execution of the Batch Loader utility at the command line. This allows for rapid data loading into an
Aras Innovator instance based upon a configuration pre-defined in an xml file. The use of the
command line executable also makes it suitable for use in a daily batch job through the use of
Windows Scheduler.
Note
The Batch Loader is a subscriber only tool. You will need to obtain a license key from Aras in order
to operate the tool.
Page 278
Unit 15 – Importing Data – Batch Loader
3 5
Preview Pane
Shows a preview of the flat file data that will be loaded into the Innovator database.
Configuration Pane
You define the file to be processed as well as appropriate parameters in this pane.
Location
The AML Template is displayed in this pane. AML templates are used to build AML
instructions for the server to process the flat file data.
Status
Status messages are presented in the status pane as the tool processes a file.
Indexes to Drop
To improve performance on very large imports, you can disable database indexes using an
alter index statement in SQL Server. Contact [email protected] if you need more
information/recommendations regarding this option.
Page 279
Developing Solutions
You configure what file will be processed as well as other parameters to the tool in the
Configuration Pane. The following fields are available:
Server – The connection URL for Aras Innovator. If all the defaults were taken during the Innovator
installation, the path should be something like: http://localhost/InnovatorServer. If unsure, please
check in IIS to get the exact path. This URL should not include reference to the /Client folder
Database – The database to which the data will be loaded. Selecting this field after defining the
connection URL will make this a pick list of available databases.
User – The user login to be used for connecting to and loading data into the database.
DataFilePath – The fully qualified path to data file that contains the data to be loaded into the
database. In our case this is C:\Parts.txt
Delimiter – The delimiter used to separate data, usually a tab (\t), or a space ( ), or a comma (,).
WorkerProcesses – The number of worker processes to be used by the Batch Loader while loading
data. Recommend using the default of 1.
Threads – The number of threads per worker process. Recommend using the default of 1.
LinesPerProcess – The number of lines in the data file that will be loaded by a single worker process.
If the worker process finishes processing all its lines and the data file has more lines to be processed,
then a new worker process will be started.
Page 280
Unit 15 – Importing Data – Batch Loader
FirstRow – The number of the row where the actual data starts. Sometimes the first row is used for
row headings. In that case, the data will start in the second row. (See FirstRowIsColumnNames
property below.)
LastRow – The number of the row where the actual data stops. Default of -1 indicates that the file
should be read until the end of the file
LogFilePath – The fully specify the name of the log file where all information and errors are to be
written by the Batch Loader.
1 – Low, recommended for automated jobs with low risk on failure. Details about start and
stop, and how many items succeeded.
2 – Medium, recommended for use while developing new Batch load job. Logs details about
failure, as well as details logged in low mode.
3 – High, recommended for debugging. Provides detail and AML about every line loaded.
FirstRowIsColumnNames – When set to True, the Batch Loader starts parsing the data file from the
second row after the FirstRow value.
Page 281
Developing Solutions
1. Select the ItemType to indicate the type of Item to be created from the imported data.
2. Use the Target Property dropdown list to choose a target property for each Column in the
delimited flat file. You can view the contents of the file in the Preview Pane to help you to
map the data.
3. Press OK when mapping is complete.
Page 282
Unit 15 – Importing Data – Batch Loader
The AML Template is used to indicate to the server on how data should be added (or merged) into
the Innovator database. The template uses standard AML statements you have learned about in
this course.
Each data column from the flat file is marked with a “@” sign followed by a number. In the example
above, the first column of the file is expected to have the “name” field.
You can modify this template file and also save it by pressing the Save key in the AML Template
Pane.
Page 283
Developing Solutions
To assist with defining a correct AML Template, the Verify action is available to check that the AML
syntax presented is correct. Any error messages will be displayed in a message box. If no errors are
found the success message displayed above appears.
Page 284
Unit 15 – Importing Data – Batch Loader
Loading Data
Status
Use the Load… action to begin the import process. The Status Pane will display the data as it is
imported and indicate success or failure.
Remember that a data log (configured in the Configuration Pane) is also available for review when
the import is completed.
Page 285
Developing Solutions
Importing Relationships
Define an external file that relates two Items
together:
Along with single items, you can also import Relationship data.
One simple way to define relationships is to create a “join” spreadsheet that indicates the source
and related Item based on some unique property.
In this example, a spreadsheet has been created that denotes a Document named AssemblyJ100
that should be related to a Help Ticket TKT-0005-2010.
Page 286
Unit 15 – Importing Data – Batch Loader
Using the Template Wizard described previously, choose a Relationship ItemType and then match
the columns of the spreadsheet with the related_id and source_id properties of the relationship.
In this example, the Document is the related Item and the Help Ticket is the source.
Page 287
Developing Solutions
Review the template to make sure that the AML syntax is correct (also check with the Verify action).
In this example, the item_number property is used to find the Document and Help Ticket in the
database and relate them together using the Help Ticket Document relationship.
Page 288
Unit 15 – Importing Data – Batch Loader
The Batch Loader can also be execute from the windows command line. The command line version
of the Batch Loader allows for the use of a known configuration that can be used in a regularly
scheduled process (e.g. adding new Users to the database).. Combined with the Scheduler Service,
the command line Batch Loader can also import data at scheduled time intervals.
Page 289
Developing Solutions
BatchLoaderCMD Arguments
BatchLoaderCMD –d {datafilename} [arguments]
Most arguments can be contained in an XML
configuration file (called with the –c switch)
File delimiter character must be defined in the
XML config file
Example:
BatchLoaderCMD –d c:\import.csv –c c:\config.xml
-t c:\template.xml
The BatchLoaderCMD executable has no user interface but accepts a number of switch arguments
which can provide connection and configuration information.
where:
(Optional arguments can either be specified in the command line or in a configuration file.
-c {config file} - path to configuration file; default is 'config.xml' if no file is specified
-lr {row number} - Last row to process in the data file; default -1
Note
Most of these parameters are optional and are generally included in the xml configuration file.
However, the command line arguments will override any values in the configuration file.
Page 291
Developing Solutions
As discussed previously in this unit, AML Templates define the instructions for loading data from an
external file.
This example shows how a series of Users could be added from a file with 5 columns of data
defined.
Note
Additional examples are available in the Aras Innovator Batch Loader 9.2 documentation.
Page 292
Unit 15 – Importing Data – Batch Loader
Summary
In this unit you learned how to use the Batch Loader utility to add new data to an Innovator
database from an outside file.
Page 293
Developing Solutions
Lab Exercise
Goal:
Be able use the Batch Loader to import data from an external file into Aras Innovator.
Scenario:
In this exercise, you will use the Batch Loader to import new Users into the system using the
spreadsheet you created earlier in this course to create a alternate client to Aras Innovator using
Microsoft Excel.
Time:
60 minutes
Steps:
1. Locate the spreadsheet you created earlier in this course to add Users to the system.
2. Change the logon name and First/Last name data to Users that do not currently exist in the
system.
4. Start the Batch Loader utility and complete the Configuration Pane to import the records from
the comma delimited file you saved above. You can use the MD5 encrypted password for
“innovator” shown in this unit as the password column by modifying the AML template.
5. Import the records and test to make sure they exist in the system.
6. Save the template file you created/modified in the Batch Loader tool and attempt to import a
different set of Users using command line mode. How could you configure the system so that
the command line Batch Loader was executed once a day to check for new Users?
_________________________________________________________________________
Page 294
Unit 16 Configuring the Scheduler
Service
Overview: In this unit you will learn how to set up a windows service that will execute a
specified Innovator Method periodically based on configured settings. This is
useful for sending reminders or processing escalations.
Page 295
Developing Solutions
The Aras Innovator Service is a Windows executable program that runs as a Windows Service. It is
used to automatically run Innovator Methods on a periodic schedule, as specified in the
InnovatorServiceConfig.xml file.
A single running instance of the Aras Innovator Service can be configured to periodically connect to
any number of Aras Innovator Servers over the network, and for each Aras Innovator Server, run any
number of Methods. The standard Windows Event Viewer is used for logging of program status and
error messages.
Page 296
Unit 16 – Configuring the Scheduler Service
1. Copy the InnovatorService.exe file and the two BAT files into any Folder.
2. Copy the file InnovatorServiceConfig.xml into the same folder.
3. Run the BAT file InstallService.bat. This program runs the standard .NET utility named
INSTALLUTIL. This program will leave a set of .NET log files in the working directory which
should be checked for error messages, and then deleted.
4. You will be prompted for a user name and password. This is the user that will have
privileges to run the Windows Service. Use a fully qualified user name
(domain_name\user_name). If the user name and password are not valid the installation
will fail.
5. Access the Services Management Console to make sure the service named “Innovator
Service” has been added to system. You can then configure when to start the service, set to
Automatic, etc. You can also edit the user name and password that will execute this service
or use the Local System Account.
Page 297
Developing Solutions
<innovator> tag is used to specify an Aras Innovator server to connect to. There can be multiple
<innovator> tags in the configuration file.
<username> is the login name that should be used for running the Methods.
<months> is the month of the year that the Method should be run. Supports a comma delimited list
of 1 through 12. January is month=1 and December is month=12.
<days> is the day of the week that the Method should be run. Supports a comma delimited list.
Sunday is day=0 and Saturday is day=6. A special value, “last”, is used to indicate the last day of the
current month.
<hours> is the hours of the day that the Method should be run. Supports a comma delimited list of
hour values from 0 through 23.
Page 298
Unit 16 – Configuring the Scheduler Service
<minutes> is the minute of the hour that the Method should be run. Supports a comma delimited
list of hour values from 0 through 59. A special value, “once”, is used to indicate the job should be
run only “once” when the <hours> criteria is met, but on which minute is not important.
<eventLoggingLevel> sets the level of detail for messages that are sent to the Windows Event
monitor.
<intervalMinutes> sets the Windows timer to control how often the InnovatorService is polled and
the <job> timing logic is tested. Any value from 1 to 60 is supported.
Page 299
Developing Solutions
Use the Windows Event Viewer to track when the Service is executed.
Page 300
Unit 16 – Configuring the Scheduler Service
Example
<innovators>
<innovator>
<server>http://localhost/Innovator10</server>
<database>DevelopingSolutions</database>
<username>admin</username>
<password>innovator</password>
<http_timeout_seconds>600</http_timeout_seconds>
<job>
<method>Scheduled Email Delivery</method>
<months>*</months>
<days>*</days>
<hours>*</hours>
<minutes> 0,15,30,45 </minutes>
</job>
</innovator>
<eventLoggingLevel>2</eventLoggingLevel>
<intervalMinutes>1</intervalMinutes>
</innovators>
In this example, the Method Scheduled Email Delivery is executed every 15 minutes. Source code
for this Method appears on the next page. The Service Interval check is set for 1 minute and
detailed reporting (service level 2) is defined.
Note
Two standard server Methods are also provided in the Solutions database to check for workflow
reminders as well as escalations. The example below shows two sample jobs that can be included in
the configuration file to run these recommended Methods on a periodic basis:
<job>
<method>Send Email Reminders</method>
<months>*</months>
<days>*</days>
<hours>0</hours>
<minutes>2</minutes>
</job>
<job>
<method>Check Escalations</method>
<months>*</months>
<days>*</days>
<hours>0</hours>
<minutes>12</minutes>
</job>
Page 301
Developing Solutions
The Scheduled Email Delivery Method uses the email method of the Item class to send an e-mail
message to a user (in this example it’s the admin).
Note
The E-mail message must have a From Identity or the email method will fail.
Page 302
Unit 16 – Configuring the Scheduler Service
Summary
In this unit you learned how to install and configure the Scheduler Service.
Page 303
Developing Solutions
Lab Exercise
Goal:
Be able use install and use the Scheduler Service to execute a Method based on a time schedule.
Scenario:
In this exercise, you will create a simple server Method that logs a message to the debug log each
time the Method is executed. You will then install and configure the Scheduler Service to call this
Method and check the log to make sure the service is running.
Time:
30 minutes
Steps:
1. Create a server Method named Schedule Test that creates a message in the debug log. Use the
WriteDebug method (CCO class) you learned about earlier in this course to write a message to
the log each time the Method is executed. Test to make sure the message is written to the log.
2. Obtain the Scheduler Service from the instructor and copy the files to a directory named
“Scheduler” on the C:\ drive.
4. Set the time interval to run the Method once every 2 minutes.
5. Start the Innovator Service and check the log file for results.
Page 304
Appendix A: Custom Search Result
Sets
Overview: There may be occasions when it is necessary to restrict the search criteria on
the Item search grid. The grid appears when a user presses the ellipsis button
or F2 on a form field representing an Item property - or when a user searches
for a related Item when building a new relationship.
Page 305
Developing Solutions
This option is useful for presenting a restricted set of Items based on the value of other Items or
conditions. In this unit, we will create a Method that prevents a user from selecting a Product unless
a Model (relationship) has been established for the Product Item.
The client side method works directly with the Query object to indicate what results should be
displayed to the user. The method must create a comma delimited list of valid Item id's that are
passed to the Query object when a user performs an Item search.
Page 306
Appendix A – Custom Search Result Sets
Page 307
Developing Solutions
Page 308
Appendix A – Custom Search Result Sets
The goal of this example is to prevent a user from selecting a Product that does not have an assigned
Model. Only Products that have an assigned Model relationship will be displayed in the search grid.
You can easily customize this query to return a different result for different use cases.
Programmatically supplying items to the search grid prevents the user from overriding the search
criteria.
Page 309
Developing Solutions
Page 310
Appendix A – Custom Search Result Sets
Remember that all relationship Items are configured with two standard properties – source_id and
related_id.
In this example, we want to invoke the custom search Method when the user attempts to add or
change the related_id of the Change Request Product relationship.
1. Display the Property form by selecting View "Properties" from the right mouse context
menu.
2. Add the custom Method and select the OnSearchDialog event.
Page 311
Developing Solutions
Summary
In this unit you learned how to customize Item searches using the OnSearchDialog Event.
Create a Method that sets defines a result set in an Item search grid based
on business logic
Page 312
Appendix B: Creating Form Dialogs
Overview: You can use Form Items that are created in Aras Innovator as custom dialog
boxes in a solution. This unit explains the steps to create and process a dialog
box that uses a standard Aras Form.
Page 313
Developing Solutions
You can create your own custom dialogs that take advantage of the Aras Innovator Form Item to
display and edit data in a solution.
Dialogs can be used as a result of selecting an Action menu or triggered by a client Method to
provide additional information or capture additional data.
Page 314
Appendix B – Creating a Form Dialog
1. Creating a form that will be displayed as the dialog. You can add named fields, buttons and
any other HTML controls that will be used in the dialog.
2. Creating a client Method that will show the dialog box based on an Action event and also
process the results.
3. Creating a client Method on the form that will populate data in the HTML controls.
4. Creating a client Method on the form to return back results to the calling Method Step 2
above.
5. Creating an Action that calls the Method created in Step 2 above.
Page 315
Developing Solutions
_item_number
_comment
Make sure to supply a name for each of the controls that will be displayed in the dialog. These
names will be used to either display or capture data from the dialog.
Page 316
Appendix B – Creating a Form Dialog
You must first get a handle to the Form created in the first step. In this example the Form is named
“Add Comment Form”.
Optionally, you can capture the Form size attributes and use them to size the dialog box to the same
dimensions. In this example if the width and height are not supplied in the Form then 500 px will be
used as the default dimensions.
Page 317
Developing Solutions
The next part of the same client Method needs to populate a parameter Object that will be used to
drive the dialog logic.
title
Defines what will appear in the windows title bar.
formID
The ID of the Form Item created in Step 1.
item
You can pass an Item to the dialog which can then be used as the context Item for other dialog
Methods that either populate or capture data from the dialog.
aras
The aras client object is required to display the dialog
isEditMode
If set to true allows editing within the dialog. If false the dialog becomes display only.
Page 318
Appendix B – Creating a Form Dialog
The next part of the client Method calls the showModalDialog function which is included in the Aras
Innovator client scripts.
Parameter Object
Discussed on the previous page
Attributes
A string containing attributes to set on the dialog window including size, scrolling, resizing, etc.
Page 319
Developing Solutions
For dialogs that will return data for processing you can obtain the results of the dialog data which
are returned in a string and use them for further processing.
In this example, a new Remark is added to the current Design Request by adding a new null
relationship and setting the _comment property as the result of the returned data (res).
Page 320
Appendix B – Creating a Form Dialog
To pre-populate the dialog create a separate client Method and attach it to the onFormPopulated
event of the Form to be used as the dialog.
If you pass an Item in the parameter object (shown on a previous page) this will become the context
Item of the Method which allows you to retrieve values from the DOM to populate the HTML form
fields.
In this example, the property “_item_number” is retrieved from the DOM and assigned to the
“item_number” field on the Form.
Page 321
Developing Solutions
You can return values back to the calling program by creating another client Method and associating
it with a control event (typically a button onClick event).
In this example the value of the field “comment” is retrieved from the form and then returned using
the setReturnValue function which is supplied another standard client function with the show dialog
logic.
Finally, the top.close() JavaScript method closes the window and control is returned to the calling
program.
Page 322
Appendix B – Creating a Form Dialog
To display the dialog from a client Action you will need to create an Action and supply the name of
the first Method created to invoke the dialog.
In this example an Item Action is used so that the context Item can be passed to the displayed dialog
box Form Methods.
Page 323
Developing Solutions
Once complete, this Action can now be used as an alternate way to quickly add a Remark to a Help
Ticket without opening/editing the Help Ticket Form.
Page 324
Appendix B – Creating a Form Dialog
Summary
In this unit you learned how to create a custom dialog using a Form Item.
Page 325
Developing Solutions
Page 326
Appendix C: Customizing a Form
Overview: When you create a Form in Aras Innovator, the form is rendered as an HTML
page at runtime. You can modify the attributes of the form or perform custom
operations on HTML controls using client Methods.
Page 327
Developing Solutions
HTML Controls allow you to provide your own HTML source code to define the visual display and
how the control will interact with the user.
Because forms use standard HTML with JavaScript you can define how the control will behave and
appear to the user.
Page 328
Appendix C– Customizing a Form
Place the HTML Dropdown control on the Form and supply the appropriate actions to be
performed.
Create a Form Event Method to populate the control using JavaScript.
Optionally, create a Form Event Method to capture the selected result into a property.
Page 329
Developing Solutions
Page 330
Appendix C– Customizing a Form
//get Vendors
var returnItm = document.thisItem.newItem("Vendor", "get");
returnItm.setAttribute("select", "name");
returnItm = returnItm.apply();
document.thisItem.setProperty("vendor", this.value);
Page 331
Developing Solutions
Page 332
Appendix C– Customizing a Form
Summary
In this unit you learned how to create define custom logic for HTML form controls.
Page 333
Developing Solutions
Page 334
Appendix D: Creating a Configurable
Grid
Overview: In this unit you will learn how to build a Configurable Grid which is used to
replace the standard relationship grid in a tear off window. Configurable grids
allow you to present related information in different ways to an end user.
Page 335
Developing Solutions
Overview
Allows creation of a custom relationship grid which
is displayed on the Item form
Can display multiple hierarchical Itemtype and
Relationship data in a single display
Grid Items manage display of complex data in a
spreadsheet format – in place editing supported
Data can be supplied using:
▫ AML Query
▫ Method
▫ Federation
Copyright © 2014 Aras All Rights Reserved. aras.com
Configurable grids are ideal for presenting complex Item relationships or hierarchically related data
in a “spreadsheet” format. You can populate the grid using an AML Query, a Method or through
Federated Items and Properties (discussed later in this course).
Page 336
Appendix D – Creating a Configurable Grid
Overview
Document
AML Query Grid
Object XPath
or Method Display
Model
A Configurable Grid is populated by creating a DOM using a standard AML Query or the return of a
Result Item from a Method.
The Grid form allows you to define columns which are supplied data with standard XPath
instructions. The output of the XPath queries result in a grid display of rows (for each Item specified
in the DOM) and columns.
Page 337
Developing Solutions
Supports Nested
Data
Replaces Standard
Relationship Grid
Once a grid has been configured, a user can then review the data presented in a spreadsheet format
where each top level Item defines a row of the grid.
Each column can represent data on the top level Item as well as related data. If more than one
related item exists from the top level Item column “nesting” is supported which will display the
contents of the nested Items in the same top level row.
Grids support both insert and delete of Items and related Items as well as editing of individual cells
(Method code required). Cell events are also available to validate or populate data using additional
Methods.
In this example, the starting item is a Customer which is related to one or more Change Request
Items (source Item) which have a request number, title and type (classification). Each request can
then be related to one or more Product Items.
When a user selects a Customer they would like to see all of the Change Requests associated with
that Customer.
Page 338
Appendix D – Creating a Configurable Grid
1 2 3
Name
Name of the Grid Item.
Merge Path
XPath Query which indicates where the results of the grid should be merged into the current
parent Item DOM if an Item is saved to the database.
Method
Client Method to populate the grid or supply additional logic after the AML Query has
executed.
Query
AML Query used to populate the DOM for the grid control use.
Page 339
Developing Solutions
Sort Order
Order of the columns displayed in the Grid from left to right.
Visible
Hide or show Grid column (useful for retrieving data that may be need for update but not
editing/display).
Label
Column name displayed grid header (support multiple languages).
Width
Size of the grid column (number of characters).
Align
Left, right, center display of data in column.
XPath
The XPath query that will be used to show data from the Item DOM (result of Query or Method).
Page 340
Appendix D – Creating a Configurable Grid
Starts Nested
If the XPath query results in multiple related Items the data should be shown in a “nested” row on
the grid. This feature allows you to display hierarchical data to a user.
Data Type
Text – normal text display.
Default – use standard Innovator display behavior for property type.
Federated – a Method will be used to calculate the value.
Bound Select – single select dropdown list bound to values in a list (created with Select
Query described later in this unit). User must choose one of the presented values.
UnBound Select - single select dropdown list created from values in a list (created with
Select Query described later in this unit). User can select a choice or enter their own.
Bound MultSelect – same as Bound Select except multiple choices are allowed (returned as
comma delimited string).
UnBound MultSelect – same as UnBound Select except multiple choices are allowed
(returned as comma delimited string).
Dependent – Item is dependent on results in another field.
Sort – this column will be used to sort on.
Sort
Specifies how the column will sorted when data is displayed in the grid. Similar to ItemType
properties OrderBy option.
Select Query
AML query used to populate dropdown bound or unbound select lists.
Select Method
Method used to populate dropdown bound or unbound select lists.
Select Form
Optional Form to be displayed to allow data entry for a column. Requires a custom Method.
Page 341
Developing Solutions
OnCopy
If a user copies a cell or row (Ctrl + C) this event is executed to process the selected row.
OnPaste
If a user pastes a cell or row (Ctrl + V) this event is executed to process the row.
On MenuInit
If a user right clicks on an editable cell a context menu is presented. This event is triggered just
before the menu is displayed.
OnMenuClick
User clicks on a context menu choice.
Page 342
Appendix D – Creating a Configurable Grid
<Result>
<Item type=’ParentItem’>
<description>Item 1</description>
<Relationships>
<related_id>
<Item type=’RelatedItem’>
</Item>
</related_id>
</Relationships>
</Item>
<Item type=’ParentItem’>
<description>Item 2</description>
<Relationships>
<related_id>
<Item type=’RelatedItem’/>
</related_id>
</Relationships>
</Item>
</Result>
Page 343
Developing Solutions
This diagram illustrates how the inDOM data is translated into a Configurable Grid for display.
The control uses a format similar to a spreadsheet to “nest” related hierarchical Items.
Page 344
Appendix D – Creating a Configurable Grid
Creating a Configurable Grid assumes you have some knowledge of the XPath query language. This
course is not designed to make you an expert in XPath but you can use some basic expressions to
query a DOM if you are not familiar with the language.
There are numerous resources for learning XPath both on-line and in many published books and
articles. A handy starting tutorial is also available on-line at:
http://articles.techrepublic.com.com/5100-10878_11-1054416.html
Page 345
Developing Solutions
These examples show some common XPath expressions used with an AML Query.
The next example gets the Relationship Item from the source Item.
The third example demonstrates how to locate a related Item from a Relationship Item.
You can also qualify the Item search by using attributes (e.g. type).
Page 346
Appendix D – Creating a Configurable Grid
Customer
This working example shows how a Change Request can be related to a Customer Item.
The users of the solution would like to be able to see all of the Change Requests that “belong” to a
Customer as well as related Product data for each request in a concise display.
Page 347
Developing Solutions
A common use for Configurable Grids is a “reverse” lookup. The current context Item is the related
Item in a relationship and the source Item(s) is the desired result.
Change Request
source_id related_id
Change Request Customer Customer
Page 348
Appendix D – Creating a Configurable Grid
Page 349
Developing Solutions
Nested Data
Once the Query has been defined, you then specify the column information including the XPath
query for each column data element.
In this example, the source Item information will be presented in the first 3 columns. A new nested
data relationship (Products) is defined on column 4.
In column 5 the Product name property is specified. Because the Product property item_number
and name are returned in the same nest, the XPath expression for column 5 uses the period (.) to
access the name property value. Note that the Starts Nested checkbox is unchecked in column 5
indicating the property belongs to the current nest level.
If you need to nest within a nest - the current position of the XPath query will be positioned at the
level set on the previously nested XPath statement.
Review these expressions with the AML Query on the previous page to see how the data will be
extracted.
Page 350
Appendix D – Creating a Configurable Grid
1
2
Name
Identity that will be allowed to work with this Grid
Grid
Name of the Configurable Grid.
In this example, a RelationshipType named Customer Change Request is created on the Customer
ItemType and then Configurable Grid named Change Request Product is applied to the
RelationshipType. When a user opens a Customer Item, the Grid will be populated.
Page 351
Developing Solutions
Nested
relationships
Once a grid has been configured, you can open the source Item and display the tab to view the grid
query. In this example, requests have been returned from the current customer.
Starting from the left, each row in the grid represents a returned Item from the AML query. Nested
relationships are shown as nested rows in the Item row.
Page 352
Appendix D – Creating a Configurable Grid
Any property that is already defined as a List datatype in an Item will automatically be displayed as a
dropdown list if you choose the “Default” Datatype setting in the Configurable Grid. Remember,
Default means to show the property using standard UI Innovator behavior.
You can also create additional drop down lists that display data from any source by creating a Select
Query or Method and using the Bound Select or Unbound Select choices.
Page 353
Developing Solutions
A simple way to create a list is to simulate a List property by creating a Query or Method that
returns Items in the following format:
<Item>
<label>First Choice>/<label>
<value>First Value</label>
</Item>
<Item>
<label>Second Choice>/<label>
<value>Second Value</label>
</Item>
Page 354
Appendix D – Creating a Configurable Grid
For more examples of Unbound and Bound selects see the QP Planning Grids provided in the
standard InnovatorSolutions database.
Page 355
Developing Solutions
Summary
In this unit you learned how to create a Configurable Grid to display and edit data using a
spreadsheet style user interface.
Page 356
Appendix D – Creating a Configurable Grid
Lab Exercise
Goal:
Be able to create a Configurable Grid to display a collection of Sales Orders related to a Customer.
Scenario:
In this exercise, you will create a Configurable Grid that displays all of the Sales Orders for a
Customer.
Supply the appropriate XPath query and property name for each column in the grid.
Sales Order (source) Items can be located using the XPath expression:
source_id/Item
Relationship Items can be accessed using the expression to access quantity (nested):
source_id/Item/Relationships/Item
Page 357
Developing Solutions
And Part Items (inside of Quantity nested property) can be located using the expression:
./related_id/Item
6. Test the Grid by opening a Customer Item and viewing the Sales Orders tab. Your result should
resemble the following:
Page 358
Appendix E: Tracking Login and
Logout
Overview: Three system events can be configured to track successful user login, failed
login and user logout. You can provide conditional business logic to extend (or
prevent) these events with a server Method. A class utility is also available to
create System Log Items which track login activity.
Page 359
Developing Solutions
System Events
Allow tracking and validation of
▫ Failed Login
▫ Successful Login
▫ Logout
Related to System Events Handler Method
Handler Methods can create a System Events Log Item
defined by a System Events Log Descriptor Template
System Events
System Events allow you track successful logins, failed logins as well as session logouts. Each event
can be associated with a System Events Handler Method that can access the current login name as
well as other session information.
An additional System Events Log Descriptor can be created for each event type that contains a log
level number (to determine when logging should occur) as well as a custom log message. Using a
provided IOM method you can create System Events Log Items in the database based on the
configuration settings in the Log Descriptor.
Page 360
Appendix E – Track Login and Logout
Page 361
Developing Solutions
3
4
1. Select Administration > System Events from the TOC to create a new event Item. Select the
Event Type from the drop down list.
2. Select one ore more server Methods that will be executed when this event is triggered.
3. Select Administration > System Events Log Descriptor from the TOC to create a new
descriptor Item. Choose the Event Type from the selection field.
4. Enter a log level number. This number indicated if the event should be triggered or not and
is compared to the System Variable named SystemEventLogLevel. If the log level number is
greater than or equal to the system event log level the event will be triggered, otherwise it
will be ignored.
5. Enter a log message that will appear in the System Events Log Item when it is created by the
system event handler Method. The following variables are available for substitution at
runtime: %login_name%, %ip_address%, %method_name%, %event_type%, %session_id%,
%comments%.
Page 362
Appendix E – Track Login and Logout
return this;
This method first stores that name of the login in a System Variable named LastLogin.
The Method then creates a new System Events Log Item using the CreateSystemLogRecord method
available in the CCO (Core Context Object) class.
Event Type (string) – "SuccessfulLogin", "FailedLogin", or "Logout" are valid system event
types.
Method Name (string) – name of the handler Method.
Login Name (string) – the user login name. A reserved object (eventData) contains an
attribute named LoginName which contains the current user's login.
Comment (string) – additional comments that are added the System Events Log Item (if a
comment has not been provided in the System Events Log Descriptor).
Page 363
Developing Solutions
Summary
In this unit you learned how to pass parameters between server event Methods.
Page 364
Appendix F: Working with
Relationship Grids
Overview: Relationships are presented to the user as a tabbed grid on a standard tear-off
window. You can react to grid events using row and cell callback Methods to
provide additional business logic for the grid.
Page 365
Developing Solutions
The standard Aras Innovator Form always contains a grid with a set of tab controls to display
relationship information to the user.
The relTabbar control is accessed from the DOM using the expression top.relationshios.relTabbar
Page 366
Appendix F - Working with Relationship Grids
Page 367
Developing Solutions
These examples are designed to be work with the Form onLoad Event.
The setTabVisible method allows you to hide or show the tab while the setTabEnabled method
enables/disables a tab control. Use the boolean true or false as the second argument to indicate
whether a tan should be shown/enabled (true) or hidden/disabled(false).
Note
This example uses the _getTabByLabel method to select a control by label name. You can also
substitute this method with the GetSelectedTab() function to act on the tab currently selected by a
user. GetSelectedTab() returns the tab id of the actively selected tab.
Page 368
Appendix F - Working with Relationship Grids
Example
The following example hides a tab labeled Customers when a Form opens. The Method is associated
with the OnLoad Form Event. A timeout has been added to allow for the form to fully display before
the tab operation is executed.
top.hideTab = function() {
if (!parent.relationships ||
!parent.relationships.relTabbarReady ||
parent.relationships.relTabbar.GetTabOrder("|") === "" ) {
setTimeout("top.hideTab", 30);
return;
}
setTimeout("top.hideTab();", 30);
Page 369
Developing Solutions
Rows
Cells
Copyright © 2014 Aras All Rights Reserved.
Relationship grids represent relationships from the current source Item. You can modify and
provide custom logic in the standard relationship grid by accessing the grid control.
Page 370
Appendix F - Working with Relationship Grids
top.relationships.reltabbar
top.relationships ROWS
CELLS
top.relationships.iframesCollection[tab_id] .contentWindow.grid
When a user selects a tab a corresponding iFrame appears based on the id of the tab. A content
window is nested in each iFrame which contains the corresponding relationship grid data in rows
and cells as shown.
Page 371
Developing Solutions
The methods shown above are current as of Version 10 SP1 of Aras Innovator and may be amended
in future releases.
Page 372
Appendix F - Working with Relationship Grids
The Field Event code can then call this function anytime the grid count is required by a control.
Note
The example above accesses a tab selected by the user. The tab id is obtained by calling the
GetSelectedTab function of the relTabbar control. Each grid is contained in a iFrame collection
which is indexed by the corresponding tab id.
Page 373
Developing Solutions
To respond to a user’s interaction with a Relationship grid, you create client Methods and associate
them with events on the Grid Rows and Cells.
Because the grid is considered a child of the current HTML document you can use the
parent.thisItem reference to access the context of the current Item associated with the grid.
Page 374
Appendix F - Working with Relationship Grids
Row events are defined on the RelationshipType template in the Grid Events tab.
Three events allow you respond to the insertion, selection or deletion of a grid row by a user.
Page 375
Developing Solutions
The OnInsertRow, OnSelectRow and OnDeleteRow all receive three arguments which allow you to
programmatically access the current Related Item, the current Relationship as well as the grid
control itself.
Page 376
Appendix F - Working with Relationship Grids
Column set in
control and cache
In this example, the cells method of the grid control is used to set the value of the column when a
new row is inserted. The column number is determined by the sort order of the properties assigned
to the relationship and is zero based.
The relationshipID is passed to the grid row event as a standard argument and is used to locate the
relationship Item in the cached DOM by using an Item method discussed earlier in the course
(getItemsByXPath).
Finally, the property is set in the client cache for the relationship so when the user saves the parent
Item this information will be saved to the database as well.
Note
You must set both the control value as well as the Item cache property for the value to be
successfully displayed and saved to the database.
Page 377
Developing Solutions
Each cell in the relationship grid is also capable of responding to a series of events while a user
interacts with the grid.
A grid cell is represented as a property value of either the relationship item or the related item
based on the configuration of the relationship.
Access the appropriate ItemType and right click on property that represents the relationship cell.
Select View Property to access the Event tab and select the appropriate event.
Note
Default Search is a deprecated event – use onSearchDialog for any new projects.
Page 378
Appendix F - Working with Relationship Grids
The client Method receives a set of standard parameters that can be used to identify the current
relationship, the related Item, the current Property name of the cell as well as its column number
(zero based).
Page 379
Developing Solutions
var relitm =
parent.thisItem.getItemsByXPath("//Item[@id='" +
relationshipID + "']");
relitm.setProperty("_comments", upperval);
In this example, the value of the current cell is retrieved using the GetCellValue method. The letters
of the string are then set in upper case using the JavaScript toUpperCase function.
The modified string is then set back into the same cell using the cells method and the DOM is
updated so the change will be reflected when the parent Item is saved to the database.
This Method is then attached to the _comments property of the Design Request Comments
ItemType using the OnChangeCell event
.
Page 380
Appendix F - Working with Relationship Grids
Summary
In this unit you learned how to create define custom logic for Relationships grids.
Page 381
Developing Solutions
Page 382
Lab Solutions
Overview: Solution code for all Lab Exercises.
Page 383
Developing Solutions
Unit 2 Solutions
1.
2.
3.
4.
Page 384
Lab Solutions
5.
6.
7.
8.
Page 385
Developing Solutions
<Relationships>
<Item type="Sales Order Remarks" action="add">
<comment_text>Modified by AML
Administrator</comment_text>
</Item>
</Relationships>
</Item>
Page 386
Lab Solutions
Unit 3 Solutions
1.
Item so = this.newItem("Sales Order", "get");
so.setProperty("multiple_shipment", "1");
so.setProperty("shipping_method", "UPS");
return so.apply();
2.
3.
Item so = this.newItem("Sales Order", "add");
so.setProperty("shipping_method", "Federal Express");
return so.apply();
4.
string d = DateTime.Now.ToString("yyMMddhhmmss");
Item so = this.newItem("Sales Order", "add");
so.setProperty("shipping_method", "Federal Express");
so.setProperty("po_number", d);
return so.apply();
Page 387
Developing Solutions
5.
Item so = this.newItem("Sales Order", "edit");
so.setAttribute("where", "[sales_order].multiple_shipment='1'");
so.setProperty("shipping_method", "UPS");
return so.apply();
6.
Optional:
string d = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss");
Item so = this.newItem("Sales Order", "delete");
so.setAttribute("where",
"[sales_order].created_on>='" + d + "'");
return so.apply();
Page 388
Lab Solutions
Unit 4 Solutions:
1. Add the appropriate debug statement to the method DebugMe.
System.Diagnostics.Debugger.Break();
Innovator inn = this.getInnovator();
Item itm = this.newItem("Sales Order", "get");
itm.setProperty("so_number", "SO-0005");
Item result = itm.apply();
string po = result.getProperty("po_number");
return inn.newResult(po);
System.Diagnostics.Debugger.Break()
Dim inn As Innovator = Me.getInnovator()
Return inn.newResult(po)
Page 389
Developing Solutions
Unit 5 Solutions
1.
string x = System.Environment.MachineName;
return this.getInnovator().newResult(x);
2.
3.
this.setAttribute('action', 'edit');
this.setProperty('ship_date', today);
return this.apply();
Page 390
Lab Solutions
Unit 6 Solutions
1. AML Prompt Method
2. Sum Method:
3. Server_Calculator_Generic:
Dim SQL As String = "select " & [function] & "(" & column & ") as "
& [function] & " from innovator." & table
Page 391
Developing Solutions
<AML>
<Item type="Part" action="Server_Calculator_Generic">
<column_name>cost</column_name>
<table>part</table>
<function>SUM</function>
</Item>
</AML>
Page 392
Lab Solutions
Unit 7 Solutions
1. Calculate Cost:
decimal total_cost = 0;
decimal unit_cost = 0;
decimal line_cost = 0;
int quantity = 0;
int count = 0;
Page 393
Developing Solutions
Unit 8 Solutions
1.
2.
Page 394
Lab Solutions
3.
Item rel =
order.createRelationship("Sales Order Remarks", "add");
rel.setProperty("comment_text", "Sales Order Rejected");
return order.apply();
Page 395
Developing Solutions
Unit 9 Solution
1. onBeforeVersion
RequestState.Add("part_type", this.getProperty("classification",
""));
return this;
2. onAfterVersion
Unit 10 Solutions
1.
Page 396
Lab Solutions
Unit 11 Solutions
1. Apply to the client OnAfterNew Event
2.
var multiple =
document.thisItem.getProperty("multiple_shipment", "0");
if (multiple==1) {
window.handleItemChange("shipping_method", "UPS");
return;
}
window.handleItemChange("shipping_method", "Federal Express");
3.
Page 397
Developing Solutions
Unit 12 Solutions
1. onBeforeAdd
conn.Close();
conn.Close()
Page 398
Lab Solutions
2. onBeforeUpdate
conn.Close();
conn.Close()
Page 399
Developing Solutions
3. onAfterGet
string sql =
@"select * from PurchaseOrder where SalesOrderID = '" + soid +
"'";
Page 400
Lab Solutions
Unit 13 Solutions
Solution for Aras_Integration:
if (so.isError())
{
StatusMessage.Text = so.getErrorString();
return;
}
StatusMessage.Text = "Changes Saved";
}
If so.isError() Then
StatusMessage.Text = so.getErrorString()
Return
End If
StatusMessage.Text = "Changes Saved"
End Sub
Page 401
Developing Solutions
if (so.isError())
{
StatusMessage.Text = so.getErrorString();
return;
}
StatusMessage.Text = "Order Removed";
}
If so.isError() Then
StatusMessage.Text = po.getErrorString()
Return
End If
StatusMessage.Text = "Order Removed"
End Sub
Page 402
Lab Solutions
Unit 14 Solutions
Sub SalesOrders()
'Connect to Server
URL = "http://localhost/Innovator100"
Db = "DevelopingSolutions100"
user = "admin": pw = "innovator"
Count = so.getItemCount
For i = 0 To Count - 1
Set indexItm = so.getItemByIndex(i)
Cells(i + 1, 1).Value = indexItm.getProperty("so_number", "")
Cells(i + 1, 2).Value = indexItm.getProperty("po_number", "")
Cells(i + 1, 3).Value = indexItm.getProperty("shipping_method",
"")
Next i
conn.Logout
End Sub
Page 403
Developing Solutions
Unit 15 Solutions
1. See example of Users template in the unit examples. You can use the Wizard to step through
the columns to create the template. You can save the template file and use it below to use the
command line option.
2. BatchLoaderCMD –d [path to source csv file] -c [path to config file] -t [path to template file]
Page 404
Lab Solutions
Unit 16 Solutions
1. Service Method to call:
Page 405
Developing Solutions
Page 406
Index
command line ............................................................ 289
A example template ..................................................... 292
actions loading data ............................................................... 285
argument passing .......................................................110 main screen ............................................................... 279
context item ...............................................................105 overview .................................................................... 278
context Item ...............................................................106 relationship data ....................................................... 286
creating ......................................................................102 template wizard ........................................................ 282
defined .......................................................................100
dialog box, custom .....................................................315 C
generic .......................................................................109
Item ............................................................................104 cancelWorkflow action................................................... 154
addRelationship method ................................................143 CCO Utilities class methods
AML WriteDebug ................................................................. 95
actions..........................................................................46 checkout method ........................................................... 138
Add ...............................................................................48 clear caches ...................................................................... 94
and/or tag ....................................................................33 client events
attributes, passing......................................................126 field............................................................................ 219
condition property attribute ........................................34 form ........................................................................... 217
creating custom actions .............................................121 form and field ............................................................ 216
date and time ...............................................................35 form event method ................................................... 225
edit action ....................................................................50 grid/row..................................................................... 376
item attributes .............................................................41 ItemType ........................................................... 211, 213
item data type properties ............................................40 OnSearchDialog ......................................................... 226
item property tags .......................................................31 tabs ............................................................................ 366
item tag attributes (primary) .......................................30 clone method ................................................................. 132
order by attribute ........................................................43 closeWorkflow action ..................................................... 154
related_id tag ...............................................................37 COM Client ..................................................................... 266
relationships tag ..........................................................36 comparing IOM and AML ................................................. 72
reverse lookup ..................................................... 39, 348 configurable grid
saved search ................................................................44 creating...................................................................... 339
select attribute.............................................................43 defining columns ....................................................... 350
where attribute ............................................................43 grid events ................................................................. 342
API on-line help .................................................................65 overview .................................................................... 336
appendItem method .......................................................146 relationship grid event .............................................. 351
apply method ...................................................... 72, 73, 132 select lists .................................................................. 353
applyAML method ..........................................................116 xpath.......................................................................... 345
applyAML method (client) ..............................................205 context item ..................................................................... 66
applyItem method (client) ..............................................205 context item, on a form.................................................. 220
applyMethod method ............................................. 116, 122 createPropertyItem method .......................................... 136
applySQL method............................................................116
Aras Object (Client) .........................................................198
attachPhysicalFile ...........................................................138
D
Debug option.................................................................... 92
B debugging
client ............................................................................ 86
batchloader server........................................................................... 87
AML template ............................................................283 displaying prompt/confirm window ............................... 200
Page 407
Developing Solutions
F
H
federated ItemType ........................................................242
federated properties.......................................................236 handleItemChange ......................................................... 222
federated property .........................................................243 hide/show tabs ............................................................... 368
federated property events ..............................................240 HTML, custom controls .................................................. 328
federation, using events .................................................245
fetchDefaultPropertyValues method ..............................136
fetchLockStatus method .................................................153
I
fetchRelationships method .............................................141 Innovator class methods
Form dialog box ..............................................................313 applyAML................................................................... 116
applyMethod ..................................................... 116, 122
G applySQL .................................................................... 116
getInnovator ................................................................ 78
generic methods .............................................................121 getItemById ............................................................... 118
geNewId method ............................................................118 getItemByKeyedName ............................................... 118
Get Controlled Item example..........................................167 getItemInDom ........................................................... 118
getAction method ...........................................................135 getNewId ................................................................... 118
getAttribute method............................................... 126, 135 getNextSequence ...................................................... 118
getBaseURL method .......................................................202 getUserID............................................................. 78, 120
getDatabase method ......................................................203 newError.................................................................... 118
getErrorCode method .....................................................152 newItem ........................................................ 76, 77, 118
getErrorDetail method ....................................................152 newResult ...................................................... 78, 79, 118
getErrorSource method ..................................................152 ScalcMD5 ................................................................... 120
getErrorString method ....................................................152 instantiateWorkflow method ......................................... 153
getID method ..................................................................135 isAdminUser method ..................................................... 203
getIdentityList method ...................................................203 isCollection method ....................................................... 134
getInnovator method........................................................78 isEmpty method ............................................................. 134
getItemById method .......................................................118 isError method ............................................................... 134
getItemByIndex method .................................................146 isLocked method ............................................................ 134
getItemByKeyedName method ......................................118 isLogical method ............................................................ 134
getItemByXPath method ................................................146 isNew method ................................................................ 134
getItemCount method ....................................................146 isRoot method ................................................................ 134
getIteminDom method ...................................................118 Item class methods
getLoginName method ...................................................203 addRelationship ......................................................... 143
getNextSequence method ..............................................118 appendItem ............................................................... 146
getProperty method .......................................................136 apply .............................................................. 72, 73, 132
getPropertyAttribute method.........................................136 attachPhysicalFile ...................................................... 138
getPropertyCondition method........................................136 boolean methods (is...) .............................................. 134
getPropertyItem method ................................................136 checkout .................................................................... 138
getRelatedItem method..................................................145 clone .......................................................................... 132
getRelationships method ................................................145 collection methods .................................................... 146
getServerBaseURL method .............................................202 createPropertyItem ................................................... 136
GetTabId method ............................................................368 Email .......................................................................... 153
getType method .............................................................135 extended methods .................................................... 153
getUserId method ...........................................................120 fetchDefaultPropertyValues ...................................... 136
getUserID method .................................................... 78, 203 fetchLockStatus ......................................................... 153
Page 408
Index
Page 409
Developing Solutions
S T
ScalcMD5 method ...........................................................120 tab control, accessing ..................................................... 368
scheduler service tabs, working with .......................................................... 366
configure ....................................................................298 this keyword ..................................................................... 66
installing .....................................................................297 toolbar, Solution Studio ................................................... 70
monitoring .................................................................300 top.aras
overview ....................................................................296 AlertSuccess/AlertError ............................................. 199
search grid, custom result sets .......................................306 Confirm/Prompt ........................................................ 200
search grid, prefilling ......................................................227 evalMethod ............................................................... 201
server events evalMethodItem ........................................................ 201
ItemType ....................................................................161 get paths .................................................................... 202
LifeCycle .....................................................................162 get URLS .................................................................... 202
overview ....................................................................160 get user info .............................................................. 203
System........................................................................360 get working directory ................................................ 202
tracking login and logout ...........................................359 utility functions.......................................................... 205
validation example .....................................................164 ValidateVote .............................................................. 204
Workflow ...................................................................163 top.aras.Object ............................................................... 198
workflow definition....................................................168 ToString method............................................................. 153
workflow validation ...................................................166
setAction method ...........................................................135
setAttribute method ................................................. 73, 135
U
setErrorCode method .....................................................152 unlockItem method ........................................................ 153
setErrorDetail method ....................................................152
setErrorSource method ..................................................152
setErrorString method ....................................................152 V
setID method ..................................................................135 Visual Studio
setNewID method ...........................................................135 adding IOM reference ............................................... 255
setProperty method............................................ 72, 73, 136 creating a connection ................................................ 256
setPropertyAttribute method .........................................136 Visual Studio and IOM .................................................... 254
setPropertyCondition method ........................................136
setPropertyItem method ................................................136
setRelatedItem method ..................................................143 W
SetTabVisible method .....................................................368 Workflow Actions
setType method ..............................................................135 cancelWorkflow......................................................... 154
showModalDialog ...........................................................319 closeWorkflow........................................................... 154
SOAP Message ................................................................261 startWorkflow ........................................................... 154
SOAP Message, sending ..................................................261 workflow definition items .............................................. 168
Solution Studio Editor .......................................................69 workflow dynamic assignments ..................................... 172
startWorkflow action ......................................................154 workflow dynamic routing ............................................. 170
system architecture ..........................................................12 workflow validation........................................................ 166
system events WriteDebug ...................................................................... 95
logging........................................................................361
Page 410