B - Advanced 7 - Projects and rulesets as XML

Purpose Purpose here is to get to know different ways of backing up a validation rule, validation ruleset, or validation project.

Description

Multiple ways exist to make backups and duplicates of the content we have created with Studio. When certain rule is made in a project and there's a need to reuse it in another project, it may be worth considering to copy/paste it directly, especially if the validation rule is complicated

Following is done here:
  1. Copying a rule
  2. Copying a ruleset
  3. Backing up project
  4. Duplicating project
  5. Deleting project

This section concludes the advanced training stage.

Instructions

1: Copying a rule

At this point, we should have a rule limiting value of Transaction/Id to be either "Id1" or "Id2". Goal of this phase is to have this logic to be applied to Header/Id as well.

We can view the rule as XML, make a slight modification to the rule and then paste the rule as a ruleset, to minimize the amount of effort.

First, we'll locate our rule, open it and view it as XML. Button for viewing the rule as XML is in the upper right corner of rule modal:

 

Clicking the button will lead us to following-looking XML

 

If we wanted, we could make changes here directly as well. However, in this case we want to copy everything here and paste it as another rule. We'll select all of the content, and click copy

Next, we shall choose a ruleset we want to have the new rule to be copied. We can select the normal, non-group ruleset here for example by pressing the settings icon and selecting "Import rule".

A new modal will open where we can paste the rule we copied earlier.


However, after pasting, our rule is exactly the same as the original. Therefore, we shall make three modifications to the XML directly

<name>Transaction_Id_valueRestrictions</name> 
needs to be changed to
<name>Header_Id_valueRestrictions</name>

Otherwise we would have two rules with the same name, which is not valid.

<context>TransactionType1</context> 
needs to be changed to
<context>HeaderType1</context>

This ensures we are targeting the correct element.

 <ruleLocationXpath>/Message/Transaction/Id</ruleLocationXpath> 
needs to be changed to
<ruleLocationXpath>/Message/Header/Id</ruleLocationXpath>

ruleLocationXpath is not used in rule execution, it is only used in where the rule is displayed in Studio. We should change this to be in the correct element, in Header instead of in Transaction.

 

After this is done, and when pressing save, we should now see the new rule in it's relevant location.

2: Copying a ruleset

We can do the same to the whole ruleset as well, by selecting ruleset XML view.

 

This allows us to copy the ruleset elsewhere, or to save the ruleset to user's computer to make a local backup.

3: Backing up project

We can use the same logic for the whole project as well, this setting is under "project dashboard" -> export project

4: Duplicating project

Since the export project will be exporting the project exactly as it is, we cannot use it directly to make duplicates of a project. This is because the unique Id Studio assigns to a project will be the same if we try to do so.

In order to quickly duplicate a project, we can use copy project within dashboard:

This open following modal:

 

Which allows us to set the destination and the name for the new project. This feature will automatically change Id's to be unique so no further tinkering is required when using this.

We can press the save here, so in next section we'll have a project to delete.

 

5: Deleting project

The project we created in previous phase should now be opened. It will also be listed in the left-hand-side navigation

This navigation panel can be opened by clicking "project list"

There are two ways to delete a project, either by clicking thrash bin here in the project list

(which is this case is somewhat hidden)

Or alternatively within project settings once the project is open

 

We should delete the project by using either of these options to keep the list more tidy. Whenever deleting content it's of course a good idea to be careful. As extra caution, backup of the project can be created first before deleting anything, good idea especially if there is actual and important validation rules present in the project.

 

This was the final section of the advanced training content. Next up will be expert level stuff, which should be fairly doable as you have made it this far.