---
title: "Lusid.Portfolio.Txn.Property.Writer"
slug: "lusidportfoliotxnpropertywriter"
updated: 2024-08-21T10:53:42Z
published: 2024-08-21T10:53:42Z
canonical: "support.lusid.com/lusidportfoliotxnpropertywriter"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.lusid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lusid.Portfolio.Txn.Property.Writer

| **Type** | **Read/write** | **Author** | **Availability** |
| --- | --- | --- | --- |
| [Data provider](/v1/docs/what-are-a-data-provider-and-a-direct-provider) | Write | Finbourne | Provided with LUSID |

Providing you have [access control permissions](/v1/docs/creating-policies-to-control-access-to-providers-for-different-luminesce-end-users), you can use the `Lusid.Portfolio.Txn.Property.Writer` provider to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that either upserts or deletes [properties](/v1/docs/properties) to or from transactions in LUSID.

> **Note:** For portfolios, portfolio groups, instruments, people and legal entities, use the [Lusid.Property.Writer](/v1/docs/lusidpropertywriter) property provider. For other entities, [configure its entity provider](/v1/docs/how-do-i-configure-luminesce-entity-providers-to-readwrite-properties) to 'inline' properties into the Luminesce catalog first.

You must construct a valid table of data to write, one property per record. `Lusid.Portfolio.Txn.Property.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 transaction property; that is, create a property if it does not exist, and update it if it does. This is the default operation if you omit `WriteAction`.
- Delete a transaction property.

**See also:** [Lusid.Portfolio.Txn.Property](/v1/docs/lusidportfoliotxnproperty)

## Basic usage

```sql
@table_of_data = <select-statement>;
select * from Lusid.Portfolio.Txn.Property.Writer where toWrite = @table_of_data;
```

## Query parameters

`Lusid.Portfolio.Txn.Property.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](/v1/docs/what-tools-are-available-to-write-luminesce-queries):

```sql
select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.Portfolio.Txn.Property.Writer' and FieldType = 'Parameter';
```

## Data fields

`Lusid.Portfolio.Txn.Property.Writer` lists the fields you can populate in your table of data to write.

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

| **Operation** | **Specify using...** | **Mandatory fields** | **Notes** |
| --- | --- | --- | --- |
| Upsert | `'Upsert' as WriteAction` (or omit) | `TxnId` `PortfolioScope` `PortfolioCode` `PropertyScope` `PropertyCode` `Value` | The `Value` field is a text field, so you should supply the property value as a string, for example `'true'&nbsp;as Value` or `'10.5' as Value` or `'2020-01-01' as Value`. Providing it is meaningful to do so, Luminesce automatically casts the value to the data type of the [underlying property type](/v1/docs/how-do-i-create-a-property-type), or raises a write error if not. For more information, and for nuances of writing time-variant and multi-value properties, see [this article](/v1/docs/using-luminesce-to-write-different-kinds-of-property-for-lusid-entities). |
| Delete | `'Delete' as WriteAction` | `TxnId` `PortfolioScope` `PortfolioCode` `PropertyScope` `PropertyCode` |  |

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](/v1/docs/what-tools-are-available-to-write-luminesce-queries):

```sql
select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.Portfolio.Txn.Property.Writer' and FieldType = 'Column';
```

## Write errors

We recommend examining the results of every write query using one or more of the `WriteError`, `WriteErrorCode` and `WriteErrorDetail` fields.

For each record in the table of data to write, `Lusid.Portfolio.Txn.Property.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.

## Examples

> **Note:** For more example Luminesce SQL queries, visit our [Github repo](https://github.com/finbourne/luminesce-examples/tree/master/examples). For more information on nuances of writing different kinds of property to LUSID entities, see [this article](/v1/docs/using-luminesce-to-write-different-kinds-of-property-for-lusid-entities).

### Example 1: Add a property to a transaction

In this example, LUSID adds a property defined as an exchange code to an existing transaction. The query defaults to the 'Upsert' action as no explicit `WriteAction` is specified.

```sql
@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Global-Equity' as PortfolioCode,
'Finbourne-Examples' as PropertyScope, 'Global-Equity13' as TxnId, 'ExCo' as PropertyCode, 'FRA' as Value;
select * from Lusid.Portfolio.Txn.Property.Writer where ToWrite = @table_of_data;
```

### Example 2: Delete a property from a transaction

In this example, the explicit use of 'Delete' as `WriteAction` deletes a property for a particular transaction.

```sql
@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Global-Equity' as PortfolioCode, 
'Finbourne-Examples' as PropertyScope, 'Global-Equity18' as TxnId, 'ExCo' as PropertyCode, 'Delete' as WriteAction;
select * from Lusid.Portfolio.Txn.Property.Writer where ToWrite = @table_of_data;
```

### Example 3: Add multiple properties to multiple transactions

In this example, eight exchange code properties are added to eight different transactions at the same time using the default `WriteAction`.

```sql
@vals = values
('Global-Equity11', 'NYSE'),
('Global-Equity12', 'LON'),
('Global-Equity13', 'FRA'),
('Global-Equity14', 'JPX'),
('Global-Equity15', 'FRA'),
('Global-Equity16', 'LON'),
('Global-Equity17', 'NYSE'),
('Global-Equity18', 'NYSE');
@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Global-Equity' as PortfolioCode, 
'Finbourne-Examples' as PropertyScope, column1 as TxnId, 'ExCo' as PropertyCode, column2 as Value from @vals;
select * from Lusid.Portfolio.Txn.Property.Writer where ToWrite = @table_of_data;
```
