Skip to content

Custom Fields

Yong Khor edited this page Oct 2, 2023 · 5 revisions

Custom Fields

Custom Fields are a powerful addition to the Forbury Self-Serve Custom Sheets module.

They give you the ability to pull through additional fields from your own custom sheets inside Forbury Models and have them available on the API via the customFields output collection.

How it works

Using specially prefixed range names, we are able to provide a custom output collection of custom outputs directly from Forbury Models to our API service.

Once setup, the workflow for getting custom fields is built into the normal upload process.

Custom sheets

The custom fields functionality is only available in conjunction with custom sheets.

All other range names will not be saved for extraction the next time a user downloads a new Forbury model.

Note: To see more on Self-Serve Custom Sheets, please see this guide.

Range name convention

The range names must start with FC_Extract_ followed by a key name.

The key name will be the key for the Dictionary<string, dynamic> customFields output.

Example

Workbook range name: FC_Extract_TransactionValue

Translates to customField: modelDto.CustomFields["TransactionValue"]

Key tooling

There are a few additional key range names for formatting the data you are extracting.

To use this tooling, you insert the tooling key name before your own custom key.

e.g. FC_Extract_Date_ValuationDate

The below table shows the currently available key tooling names and actions:

Key name Action
Date Converts the data to a date format used by the rest of the API yyyy-MM-dd.
Transpose Transposes an array of values from Excel.
TransposeDate Transposes an array of values from Excel and converts to date format (see above).

Workbook Versioning

The nature of the self-serve custom sheets means that any changes to that sheet will be automatically released to you the next time a user downloads a new Forbury Model.

The range names you setup during the building of a custom sheet will be preserved and carried through into each release of the Forbury Model.

Note: To see more on Self-Serve Custom Sheets, please see this guide.

Example usage

Once you have setup your range names within your custom sheets, you are ready to start extracting this data from future uploads.

...

public class ForburyExtractService
{
    ...
	
    public void HandleCustomFields(ModelDetailedDto modelDto)
    {
        var customFields = modelDto.CustomFields;
		
        if (customFields != null)
        {
            if (modelDto.CustomFields.TryGetValue("TransactionValue", out var transactionValue))
            {
                // Do work here
                ...
            }
        }
    }
}

Clone this wiki locally