Views:
TypeRead/writeAuthorAvailability
Data providerWriteFinbourneProvided with LUSID

The Lusid.Person.Writer provider enables you to write a Luminesce SQL query that either upserts or deletes one or more person entities in LUSID, such as portfolio managers, traders and so on.

Note: The LUSID user running the query must have sufficient access control permissions to both use the provider and interact with person data in LUSID. This should automatically be the case if you are the domain owner.

You must construct a valid table of data to write, one person per record. Lusid.Person.Writer lists the fields (columns) available to populate with values for each record, and has a set of parameters to help you construct a valid table.

Your query can use the WriteAction field to perform one of the following operations:

  • Upsert a person entity; that is, create a person if it does not exist, and update it if it does. This is the default operation if you omit WriteAction.
  • Delete a person entity.

See also: Lusid.Person

Prerequisites

Note: You only need perform the operation in this section once, for both Lusid.Person.Writer and Lusid.Person.

A person entity must have at least one user-specified identifier from which LUSID can generate a unique internal LUID. Consider the following JSON representation of a person entity in LUSID: 

"displayName": "John Doe",
"description": "A portfolio manager in US investments",
"lusidPersonId": "LUID_00003D6X",
"identifiers": {
  "Person/PortfolioManagers/ManagerId": {
     "key": "Person/PortfolioManagers/ManagerId",
     "value": {
       "labelValue": "PortMan1"
     },
     "effectiveFrom": "0001-01-01T00:00:00.0000000+00:00"
   }
}

It's important to note that Lusid.Person.Writer does not know anything about the Person/PortfolioManagers/ManagerId identifier out-of-the-box. For this reason, a field representing this identifier cannot be listed in the Luminesce catalog by default. In order to create a person entity, you must first:

  1. Use Lusid.Property.Definition.Writer to create an identifier with a Domain of Person, a ConstraintStyle of Identifier and a Lifetime of Perpetual.
  2. Run a special SQL query to 'inline' the identifier as a field in Lusid.Person.Writer, so that it appears in the catalog and can be written to. For example:
    @identifiersToCatalog = values
    ('Person/PortfolioManagers/ManagerId', 'PortManId', True, 'An identifier for this person as a portfolio manager');
    
    @config = select column1 as [Key], column2 as Name, column3 as IsMain, column4 as Description from @identifiersToCatalog;
    
    select * from Sys.Admin.Lusid.Provider.Configure
    where Provider = 'Lusid.Person.Writer'
    and Configuration = @config;

You can now use Lusid.Person.Writer in the normal way to write values for the standard DisplayName and Description fields, and also for the newly-added identifier field (which is listed in the catalog as PortManId).

Basic usage

@table_of_data = <select-statement>;
select * from Lusid.Person.Writer where toWrite = @table_of_data;

Query parameters

Lusid.Person.Writer has parameters that help you construct a valid table of data to write.

Note: The toWrite parameter is mandatory and used to actually write the table of data into LUSID.

To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:

select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.Person.Writer' and FieldType = 'Parameter';

Data fields

Lusid.Person.Writer lists the fields you can populate in your table of data to write.

Note: Do not write to the LusidEntityId field. It is a read-only field that can be used to retrieve the LUID that is automatically generated when you create a person.

Depending on the operation you want to perform, the following fields are mandatory to include in the table of data:

OperationMandatory fields in table of data to write
UpsertDisplayName
Description
A value for the pre-defined identifier field (see Prerequisites above)
DeleteA value for the pre-defined identifier field (see Prerequisites above)

To list all available fields, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a suitable tool:

select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.Person.Writer' and FieldType = 'Column';

Write errors

We recommend examining the results of every write query using one or more of the WriteErrorWriteErrorCode and WriteErrorDetail fields.

For each record in the table of data to write, Lusid.Person.Writer returns an error code. If the operation is successful, the error code is 0. If unsuccessful, a positive error code and explanation help you discover why LUSID considers the operation invalid.

For example, the query:

@table_of_data = select 'John Smith' as DisplayName, 'A generic description for a person' as Description;
select WriteErrorCode, WriteError, WriteErrorDetail from Lusid.Person.Writer where toWrite = @table_of_data;

...fails because no identifier field and value were provided in the query.

Examples

Note: For more example Luminesce SQL queries, visit our Github repo.

Example 1: Add a person

@table_of_data = select 'PortMan1' as PortManId, 'John Doe' as DisplayName, 'A portfolio manager in US investments' as Description;
select * from Lusid.Person.Writer where ToWrite = @table_of_data;

Example 2: Remove a person

@table_of_data = select 'PortMan6' as PortManId, 'delete' as WriteAction;
select * from Lusid.Person.Writer where ToWrite = @table_of_data;

Example 3: Add multiple people

@vals = values
('PortMan1', 'John Doe', 'A portfolio manager in US investments'),
('PortMan2', 'John Smith', 'A portfolio manager in UK investments'),
('PortMan3', 'Juan Perez', 'A portfolio manager in South American investments'),
('PortMan4', 'Jan Jansen', 'A portfolio manager in Dutch investments'),
('PortMan5', 'Lieschen Muller', 'A portfolio manager in German investments'),
('PortMan6', 'Jacques Martin', 'A portfolio manager in French investments');
@table_of_data = select column1 as PortManId, column2 as DisplayName, column3 as Description from @vals;
select * from Lusid.Person.Writer where ToWrite = @table_of_data;