Select Page

Patterns & Practices: Schema Importing and Binding

by | Aug 27, 2019

Your rule application is like your house: both benefit from a strong foundation.

For rule applications, the entity structure (also called the schema) is the foundation. The schema is made up of one or more entities. The entities are often related to each other, but this is not a firm requirement.

While you can manually build your schema and define your fields, there are other techniques that can be used to import and bind your schema from other formats and other systems. This will simplify your data model creation and maintenance, saving you time and effort.

With irAuthor, you can import your schema from a JSON snippet or bind it to an .XSD file, a database, or a .NET Assembly. Finally, if you have our authoring extension for CRM (irX) you can bind to your schema to the entities and fields from Microsoft Dynamics or Salesforce. I’ll detail each of these options below.

JSON Snippet

With irAuthor, you can inherit your schema from a JSON snippet. Building your schema from an existing JSON snippet is commonly used when integrating with an existing REST service API. On the Home ribbon in irAuthor, you should find a section labeled “Schema” with options to import or export. Under the “Import” option, there is an option to import your schema from a JSON snippet as shown below.

 

Import JSON

 

After you select “From JSON Snippet”, you can navigate to the desired JSON file. You will need to name the Root Entity as demonstrated below. The schema source will still be internal and not bound, but this can speed up the creation of your entities.

 

Schema source and Entity Structure

 

.NET Assembly

One of the most common techniques for integrating your schema to the calling application is to bind your schema to a .NET assembly file. To do this, first you will want to go the Schemas section, select “Add” and select “.NET Assembly Schema”. In the “Path” block you will need to navigate to the desired .dll file. Of course, once the file is selected, you can then select the global entities that are available for import.

 

.NET Schema Assembly

 

One additional feature that comes with binding your scheme to a .NET Assembly is that it allows you to incorporate object instance methods as custom authoring functions. These can be called using expressions and Execute Method action.

Binding to a Database

The second technique for binding your schema is to inherit your schema from a database. To do this, first you will want to go the Schemas section of irAuthor, select “Add” and select “Database Schema”. In the subsequent windows, you will need to set up the provider and connection properties.

 

Data Link Properties

 

Once you have established the connection, you can select the desired tables to be bound to as entities to your schema by checking the appropriate boxes under “Include” (see below). When all desired tables are selected, click on the “Apply” button and all selected tables and their associated fields will created as entities and their attached fields. Any entities and fields not associated with this schema will be removed. Also, if the relationships have been established in the database, and if the “Create child fields” box is selected, entity fields or collections will be created to reflect one-to-one or one-to-many relationships, respectively.

 

Binding Entities and Schema from Database

 

XSD

The next technique for binding your schema is to bind it to an XML Schema Definition (XSD) file. To do this, first you will want to go to the Schemas section of irAuthor, select “Add” and select “XML Schema”. In the “Path” block you will need to navigate to the desired .XSD file. Once selected, just as with binding the Database schema outlined above, we can select the global entities that are available for import.

 

Binding Schema in XML Schema Definition (XSD) file

 

Additional options can be found in the “Advanced” settings, with several useful options taking the enumeration restriction fields and binding them to value lists or creating constraints.

 

Advanced Settings for Schema Binding

 

Once the desired options and entities have been selected, you can click on the “Apply” button and all entities and fields attached to the entities will be created, just as with the database schema process outlined above.

Dynamics and Salesforce

Users of irX for Dynamics or irX for Salesforce can inherit their schemas from their Microsoft Dynamics or Salesforce environment. While the products are different, the techniques managing your schema are identical. First, you need to navigate to the Dynamics or Salesforce ribbon as shown below, and select “Manage”.

 

irAuthor Dynamics Tab

irAuthor Salesforce Tab

 

Then, you need to go to the connection and credential information for your Dynamics or Salesforce instance. When complete, select “Use This”.

Configure Connection Setup

In the subsequent window, you can navigate the across the available entities and select the desired fields and click the “Update” button when complete. Note that relationships between the entities will also be inherited and value lists may be imported into your schema, as well.

Select Entities and Fields

Customizing Your Schema After Import

If you have modified the source of your schema, it can be re-bound and updated to easily maintain your data model. However, sometimes additional fields or entities may be needed to assist you in building and authoring your rules but does not need to exist in the calling application. You can add in additional fields and entities for internal use without modifying the bound schema simply by adding the field(s) or collection and selecting the “Temporary” option under the “Storage” section.

 

Customizing Your Schema After Import

 

This will allow you to use the temporary field in your rules and calculations for internal use without the requirement to modify the schema in your calling application.

Conclusion

Inheriting or binding your schema from an external source can greatly simplify your data model creation and maintenance. We have multiple options available to allow for the greatest parity and fidelity to our calling application, while maintaining the flexibility transparency for creating your business rules.

Questions? Comments? Feel free to let me know your feedback below.

BLOG POSTS BY TOPIC:

FEATURED ARTICLES:

STAY UP TO DATE

We’d love to share company and product updates with you! Please enter your email address to subscribe to monthly updates from InRule. 

If at any time you want to unsubscribe, you can easily do so by clicking “unsubscribe” at the bottom of every message we send or visiting this page.