SDKs
...
Tutorials
Best Practices

Custom Fields Usage

10min

At the heart of software development, custom fields stand as essential key-value pairs that empower developers to intricately define and deliver personalized information to end-users through licensing.

This approach offers a range of applications, such as defining distinct license types like development, academic, government, or commercial, establishing designated account managers, facilitating seamless notification delivery, and even transmitting JSON data directly to the application.

This tutorial aims to help you grasp the use, implementation, and management of custom fields, enhancing your proficiency in software development.



Prerequisites

  1. Completed the Getting Started Tutorial, including:
    • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
    • Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
    • Activated a license of any type.
    • Implemented routine local and online checks within the application.

Understanding Custom Field Usage

Some examples of usage scenarios for custom fields include:

Product Identification and Differentiation:

With custom fields, you can effortlessly categorize multiple products under the same custom field key but with distinct values, streamlining differentiation.

This minimizes code adjustments between product types, requiring only minor updates such as the product code and possibly a key and user information.

Additionally, renaming a product becomes hassle-free – by creating a custom field for the product name and updating it on the LicenseSpring platform.

Seamless Notifications:

Imagine creating a custom field object labeled 'Notification' where the value serves as your notification message. Should you wish to modify your message, it's a breeze.

Navigate to your product's custom fields, locate the 'Notification' key, and update the value with the new message.

Once users update their licenses through online checks, the new notification message is seamlessly integrated.

Tailored Edition Configuration:

Exploit custom field values to configure available editions for end-users without requiring separate software distributions.

For instance, a LicenseType custom field could embody values like "lite," "standard," or "pro."

Depending on the custom field value associated with a license, users can access different editions of the application, eliminating the need for multiple binaries.

Defining Custom Fields

To integrate a custom field for your chosen product, start by navigating to the desired product.

Within the interface, locate and click on the designated "Custom Fields" tab.

Here, you'll find the option to initiate the customization process by selecting "Add Custom Field."

On the pop-up, take the opportunity to define the default key-value pairing, effectively establishing the foundation for your custom field's configuration.

How to define a new custom field.
How to define a new custom field.

Specify the default key-value pair for the new custom field.
Specify the default key-value pair for the new custom field.


Adjusting Value of a Custom Field

Modifying the value of a custom field is a flexible option available to you at any point.

Note: To learn how to programmatically set a new value to your custom fields when issuing a license by looking at the documentation on our Order Web hook.

Begin by generating the new license. For detailed instructions on how to issue a new license, refer to Issuing New Licenses.

Once the new license has been created, locate it within the system and access the license screen.

Here, you'll find the "Custom Fields" option; select it.

Navigate to the custom field of the license, and click on the pencil tool in order to edit the value.
Navigate to the custom field of the license, and click on the pencil tool in order to edit the value.


Utilize the pencil tool to trigger a pop-up window, enabling you to modify the value associated with the custom field for that specific license.

Set new value for your custom field.
Set new value for your custom field.


Retrieving Custom Fields

A custom field essentially consists of a pairing of a key and a value. All the custom field data is stored within the local license.

Accessing this data is achieved through:

C++
C#
Java
Swift
Python


Upon license activation, whether through online or offline means, the resultant local license file encompasses all associated custom fields.

Nevertheless, considering the dynamic nature of custom fields that can be introduced, removed, or modified post issuance and activation, an alternative method to refresh your local license file with any such alterations involves conducting an online check as shown one our License Checks tutorial.