...
Code Block | ||
---|---|---|
| ||
$Database.ImportFromXml({ // Save employee
Parameters : {
TargetSchema : 'HR',
TargetTable : 'Employee'
},
XPath : 'Identities/Identity', // Find rows under Identities/Identity xpath
ColumnsXPath : 'Employee', // Fetch column values from Employee. Final xpath
Map : function(employeeNode) {
$Database.Get({ // Fetch matching records from database
Parameters : {
TargetSchema : 'HR',
TargetTable : 'OrganizationUnitPositionMembers'
},
Where : {
Criteria : [
{ Name : 'Employee', Value : employeeNode.Evaluate('Id') }, // "Employee must equal to Employee/Id xpath value."
{ Name : 'RegistryNumber', Value : '%2', Comparison : 'Like', Condition : 'Or' } // Another criteria just for sample. "or RegistryNumber must ends with 2"
]
}
})
.DeleteAll() // Delete existing all rows
.CreateNew(function() { // Create a new row
this.Employee = employeeNode.Evaluate('Id'); // Set Employee column to "Employee/Id" xpath value.
this.OrganizationUnitPosition = employeeNode.Evaluate('Employee/Position'); // Set OrganizationUnitPosition column to "Employee/Position" xpath value.
})
.Save(); // Save this table.
}
}); |
...