My First Pattern , versão em Português - BR
Mi Primer Pattern , version en Español
The Pattern will generate a SDT object representing the structure of a given transaction.
For instance, given the Country transaction:
the following SDT will be generated:
The steps are:
1. Read Creating a New Pattern in order to understand all relationated concepts about GeneXus Patterns and the necessary requirements to develop a Pattern.
Note: If you want to continue developing the Pattern without reading the documentation on step 1, you should install GeneXus X, GeneXus Platform SDK and Visual Studio 2005 or higher
2. Create a New Visual Studio Project: File->New->Project
3. Select GeneXus Pattern Template:
4. Enter data according to your preferences, press Next
5. Select Transaction as object for the pattern to be applied:
6. Enter type and name for the object to be generated, press Next
7. Indicate that GeneXus will be launched after making Start of your project. In order to do this in Visual Studio go to: Project->MyFirstPattern Properties->Debug and indicate the path to GeneXus.exe on Start external program
8: Copy the following code into the template to create the SDT structure (SDTSDTStructure.dkt) below this code: <Part type="<%= PartType.SDTStructure %>">:
<%--
Sample SDT Structure definition
--%>
<%-- Indicate that the generated SDT object will be Collection, this will take place adding a property with Name = AttCollection and Value = True --%>
<Level Name="<%= Object.Name %>">
<LevelInfo guid="<%= Guid.NewGuid() %>">
<Properties>
<Property>
<Name>AttCollection</Name>
<Value>True</Value>
</Property>
</Properties>
</LevelInfo>
<%-- Process the list of attributes of the transaction where the pattern is being applied --%>
<% foreach (TransactionAttribute trnAtt in myInstance.ParentObject.Structure.Root.Attributes)
{
%>
<%-- Create a field into the "SDT" using the same Name and Description of the transaction attribute (trnAtt), --%>
<%-- and the field type will be based on the attribute type --%>
<Item guid="<%= Guid.NewGuid() %>" name="<%=trnAtt.Name%>" description="<%=trnAtt.Attribute.Description%>">
<Properties>
<Property>
<Name>idBasedOn</Name>
<Value>Attribute:<%=trnAtt.Name %></Value>
</Property>
</Properties>
</Item>
<%-- Process the levels of the transaction --%>
<%
}
foreach (TransactionLevel level in myInstance.ParentObject.Structure.Root.Levels)
{
%>
<%-- For each level of the transaction, a level into SDT object will be created and the same name and description will be assigned. In addition it will be marked as Collection --%>
<Level Name="<%=level.Name%>">
<LevelInfo guid="<%= Guid.NewGuid() %>">
<Properties>
<Property>
<Name>Name</Name>
<Value><%=level.Name%></Value>
</Property>
<Property>
<Name>AttCollection</Name>
<Value>True</Value>
</Property>
</Properties>
</LevelInfo>
<%-- Process the attributes of each level and create a field with type based on the attribute level type --%>
<%
foreach (TransactionAttribute trnAtt in level.Attributes)
{
%>
<Item guid="<%= Guid.NewGuid() %>" name="<%=trnAtt.Name%>" description="<%=trnAtt.Attribute.Description%>">
<Properties>
<Property>
<Name>idBasedOn</Name>
<Value>Attribute:<%=trnAtt.Name %></Value>
</Property>
</Properties>
</Item>
<%
} %>
</Level>
<%
} %>
</Level>
</Part>
9. Do Rebuild All
10. Press F5
11. Apply the pattern!!