---
url: https://gudhub.com/ru/docs/utils/populate-with-item-reference/
title: "Populate With Item Reference\n                #"
description: "This method allows to populate items with item reference. That means you can connect items from different applications by ite reference. It allows to take data"
lang: uk
updated: 2026-09-11T12:41:53.876Z
---

# Populate With Item Reference [#](https://gudhub.com/ru/docs/utils/populate-with-item-reference/#populate-with-item-reference)

This method allows to populate items with item reference. That means you can connect items from different applications by ite reference. It allows to take data from certain field and populate another item with it. **populatedWithItemRef** can make such connections between a big number of applications.

This method accepts six arguments:

| Name | Type | Description |
| :-- | :-- | :-- |
| sorceItemsRef | `array` | _items that are used as reference for item\_ref_ |
| srcFieldIdToCompare | `number` | _field ID that is used to find similar items in source and destination arrays_ |
| destinationItems | `array` | _items that are used to save item\_ref to sorseItemsRef_ |
| destFieldIdToCompare | `number` | _field ID that is used to find similar items in destination array_ |
| destFieldForRef | `number` | _contains the ID of field where item\_ref will be saved_ |
| app\_id | `number` | _application ID that is used to generate item\_ref value_ |

At first **populateWithItemRef** checks connection between _sorceItemsRef_ and _srcFieldIdToCompare_. It does it with the help of _srcFieldIdToCompare_ and _destFieldIdToCompare_. If the connection is detected, _destFieldForRef_ will be updated with source item reference.

## Item Reference [#](https://gudhub.com/ru/docs/utils/populate-with-item-reference/#item-reference)

The destination item will have the object reference as a field\_value. It consists of source application ID and source item ID:

Копировать

```json
{
    "field_value": "27823.2987934"
}
```

More detail about item reference you can read in [Item Reference](https://gudhub.com/ru/docs/gh-elements/item-reference/).

## Example [#](https://gudhub.com/ru/docs/utils/populate-with-item-reference/#example)

Копировать

```js
import GudHub from '@gudhub/core';
const gudhub = await new GudHub();
const APPID = "27823";

let srcFieldIdToCompare = 645888;

let destFieldIdToCompare = 645900;

let destFieldForRef = 648741;

let sorceItemsRef = [{
  "item_id": 2987934,
  "fields": [{
      "field_id": 645888,
      "field_value": "GudHub",
      },
      {
        "field_id": 645887,
        "field_value": "John",
      }]
  }
];

let destinationItems = [{
    "item_id": 2993230,
    "fields": [{
        "field_id": 645900,
        "field_value": "GudHub",
        },
        {
          "field_id": 648741,
          "field_value": "Johana",
          }]
  }
];


// populate items with item reference
let populatedWithItemRef = gudhub.populateWithItemRef(sorceItemsRef, srcFieldIdToCompare, destinationItems, destFieldIdToCompare, destFieldForRef, APPID)
 
populatedWithItemRef.forEach(item => {
  console.log("item_id:", item.item_id)
  console.log(item.fields)
});
```

The method returns an array of objects which in turn contain of two properties:

Копировать

```json
[
    { 
    "field_id": 645900, 
    "field_value": "GudHub" 
    },
    { 
    "field_id": 648741, 
    "field_value": "27823.2987934" 
    }
]
```
