Relationships


Introduction

Often a record can have a field that relates to another record in another page, much like in a relational database. XaitCPQ fields can have relationships defined that means they require a value from another page to create the link.

Using Relationships

You will see in some of the metadata examples that some fields contain a Relationships field similar to the following;

"Relationships": [
    {
        "Id": "d254366e-3fe5-e511-80cd-00155d138e03",
        "From": {
            "Id": "a2983d68-3fe5-2311-80cd-0015872d8e03",
            "Name": "CurrencyGuid"
        },
        "To": {
            "Id": "ae983d68-3fe5-e819-80cd-00116d2d8e03",
            "Name": "Guid"
        },
        "LinkEditStyle": 0,
        "Link": {
            "Page": null,
            "Template": null
        }
    }
]

In this example, you can see that the From field references a field on the current page you are working on, whereas the To field references another field (most likely from another page). In the example above it shows there is a relationship from the CurrencyGuid field to another field called Guid. Although the data doesn't show what page the CurrencyGuid links to, we can call the following URL to get all of the possible values for that relationship;

https://ofd-api.blueprintcpq.net/data/Lookup/relationship/d254366e-3fe5-e511-80cd-00155d138e03

As you can see, the relationship identifier at the end of the URL is the same as the one sent with the metadata for the relationship. This will return a structure similar to the following containing the possible values and the human readable values for the field;

[
    {
        "Id" : "a387933d-73e3-4275-8319-2bb267a0c677",
        "HumanReadableValue" : "AUD"
    }, {
        "Id" : "06989b81-42df-4bad-9ed7-1f2a4d577a85",
        "HumanReadableValue" : "CAD"
    }, {
        "Id" : "d66b484a-ac2b-4b6a-b88c-0fc647169d28",
        "HumanReadableValue" : "CHF"
    }, {
        "Id" : "be70a9d5-b798-4978-825f-ff5d1d2c6c44",
        "HumanReadableValue" : "DKK"
    }, {
        "Id" : "e4517d05-1f12-4513-865c-4b38f0395906",
        "HumanReadableValue" : "EUR"
    }, {
        "Id" : "7c1f3f15-6587-42d2-9c64-4ae0e6856c9f",
        "HumanReadableValue" : "GBP"
    }, {
        "Id" : "0759613e-9c0f-4794-adb9-ec07e8fef83e",
        "HumanReadableValue" : "JPY"
    }, {
        "Id" : "c2c28e7e-e329-4ed3-9cda-fd739f5e1b19",
        "HumanReadableValue" : "NOK"
    }, {
        "Id" : "47141195-668b-4424-bfaa-1925b2fbdb7f",
        "HumanReadableValue" : "NZD"
    }, {
        "Id" : "3e0f1f0e-0423-49fe-ac03-3260e10ec980",
        "HumanReadableValue" : "PLN"
    }, {
        "Id" : "0dd2469d-58fd-4b6f-804b-24b6e258ea08",
        "HumanReadableValue" : "SEK"
    }, {
        "Id" : "40c74720-9e86-4a7c-a04c-0d39bdd39b82",
        "HumanReadableValue" : "TRY"
    }, {
        "Id" : "260e247e-f810-4f3d-93db-e870fadbc74f",
        "HumanReadableValue" : "$"
    }
]

You can then use one of the Id values as the value of the field. The human readable field is just for ease of use.