Fetching Entries

🔂 Retrieve data with our Fetching Entries function.

Fetching entries refers to the process of retrieving specific information or records. Here's an example of how you can configure and use these functions:

async function script(C) {
    const currentEntry = await C.getCurrentEntry();

    const currentEntryAsIV = await C.getCurrentEntry({ responseType: "iov" });
    
    const currentEntryWithSubrecordsAndAssociations = await C.getCurrentEntry({
        responseType: "fov",

        loadSubrecords: true,
        subrecords: [
            {
                internalId: "kalysys-dependencies",
                responseType: "fov",
            },
        ],

        loadAssociations: true,
        associations: [
            { 
                internalId: "bug-report",
                linkedFieldInternalId: "related-backlog-items", 
                responseType: "fov",
            },
            {
                internalId: "kalysys-customer-feedback",
                responseType: "fov",
            },
        ],
    });

    const getEntryResponse = await C.getEntry({
        entryId: 737466,
        recordInternalId: "bug-report", 
    });

    const getSpecificEntries = await C.getEntry({
        entryIds: [737466],
        recordInternalId: "bug-report", 
    });

    const filteredEntries = await C.filterEntries({
        filter: [
            {
                subject: "owner",
                requestType: "i",
                type: "array",
                operator: "any_of",
                value: [23643],
            },
        ],
        recordInternalId: "backlog-items",
    });

    return {
        filteredEntries,
        getSpecificEntries,
        getEntryResponse,
        currentEntry,
        currentEntryAsIV,
        currentEntryWithSubrecordsAndAssociations,
    };
}

Let's break down each component:

1) Fetch the Current Entry

Here, entryId and recordInternalId is taken from the event.

const currentEntry = await C.getCurrentEntry();

2) Fetch the Current Entry as an Internal View

In any of the functions relating to fetching entries, you can pass values responseType.

const currentEntryAsIV = await C.getCurrentEntry({ responseType: "iv" });

3) Fetch the Current Entry with Sub Records and Associations

Similarly, in any functions relating to fetching entries, you can have options to load sub records or associations.

const currentEntryWithSubrecordsAndAssociations = await C.getCurrentEntry({
        responseType: "fov",
        loadSubrecords: true,
        subrecords: [
            {
                internalId: "kalysys-dependencies",
                responseType: "fov",
            },
        ],
        loadAssociations: true,
        associations: [
            { 
                internalId: "bug-report",
                linkedFieldInternalId: "related-backlog-items", 
                responseType: "fov",
            },
            {
                internalId: "kalysys-customer-feedback",
                responseType: "fov",
            },
        ],
    });
📘

Info:

only pass linkedFieldInternalId if there are multiple linked fields.

4) Fetch a Specific Entry by ID

If not passed, the current record's internal will be taken.

const getEntryResponse = await C.getEntry({
        entryId: 737466,
        recordInternalId: "bug-report", 
    });

5) Fetch Specific Entries by IDs

If not passed, the current record's internal will be taken.

const getSpecificEntries = await C.getEntry({
        entryIds: [737466],
        recordInternalId: "bug-report", 
    });

6) Fetch Entries Based on Filter Criteria

Use filterEntries() to retrieve entries that match one or more filter conditions.

const filteredEntries = await C.filterEntries({
    filter: [
        {
            subject: "owner",
            requestType: "i",
            type: "array",
            operator: "any_of",
            value: [23643],
        },
    ],
    recordInternalId: "backlog-items",
    limit: 25,
    page: 0,
});

    return {
        filteredEntries,
        getSpecificEntries,
        getEntryResponse,
        currentEntry,
        currentEntryAsIV,
        currentEntryWithSubrecordsAndAssociations,
    };
}
📘

Note

For more information about the available parameters and pagination options, see the Workflow Functions: filterEntries documentation.


Output

Depending on the fetching function you use, the returned data may include:

  • The current entry.
  • The current entry as an internal view.
  • The current entry with its subrecords and associations.
  • One or more specific entries based on their IDs.
  • Entries that match the specified filter criteria.

📌 Need Help?

If you require assistance or encounter any issues, please don't hesitate to contact us for further support.