B - Advanced 7 - Projects and rulesets as XML
Table of contents
- 1. Purpose
- 2. Description
- 3. Instructions
- 3.1.1. 1: Copying a rule
- 3.1.2. 2: Copying a ruleset
- 3.1.3. 3: Backing up project
- 3.1.4. 4: Duplicating project
- 3.1.5. 5: Deleting project
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
This section concludes the advanced training stage.
Instructions
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 buttton 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.
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.