# Attach to Record

## From Script:

### **Attach Label to Record - Automated (Server-side) -** Attach a barcode label to a record via automation or background process:

1. Include the code below in any area where server-side scripting is allowed:

```javascript
var barHelper = new x_yala_bargen.BarcodeGeneratorHelper();
barHelper.saveBarcodePDF(barcodeID, tableName, recID, destTable, destID, true);
```

* **barcodeID**: SysID of the **Barcode Generator** record to use for barcode generation
* **tableName**: Table of the record being referenced for barcode generation
* **recID**: SysID of the record being reference for barcode generation
* **destTable**: Table where the resulting PDF should be attached
* **destID**: SysID of the record to which the resulting PDF should be attached

{% hint style="info" %}
This option utilizes server-side barcode generation. The resulting file type is PDF.
{% endhint %}

### **Attach Barcode to Record - Automated (Server-side) -** Attach a barcode part to a record via automation or background process:

{% hint style="info" %}
This method attaches a **Barcode Part**, not an entire **Barcode Generator** label.
{% endhint %}

1. Include the code below in any area where server-side scripting is allowed:

```javascript
var barHelper = new x_yala_bargen.BarcodeGeneratorHelper();
barHelper.saveBarcodeSVG(barPartID, tableName, recID, destTable, destID);
```

* **barPartID**: SysID of the **Barcode Part** record to use for barcode generation
* **tableName**: Table of the record being referenced for barcode generation
* **recID**: SysID of the record being reference for barcode generation
* **destTable**: Table where the resulting SVG should be attached
* **destID**: SysID of the record to which the resulting SVG should be attached

{% hint style="info" %}
This option utilizes server-side barcode generation. The resulting file type is SVG.
{% endhint %}

## From Form:

### **Attach Label to Record from Label Button - Attach a barcode label using the built-in Attach button:**

1. Enable the 'Attachable' option on the **Barcode Generator** record for the desired barcode label
2. Any place where the in-browser view of the barcode label is enabled (form, dialog box (modal), ui page, widget), the 'Attach' button can be clicked to attach the barcode label to a record.

<figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2Fym2ucstPJmAnd9gHc5FG%2FScreenshot%202024-05-22%20at%209.17.30%E2%80%AFAM.png?alt=media&#x26;token=aeedbfa4-07d5-4c93-af69-c1c780aa72ac" alt="" width="266"><figcaption><p>Attach Label</p></figcaption></figure>

{% hint style="info" %}
All options to attach barcode labels from label utilize client-side barcode generation. The resulting file type is PNG.
{% endhint %}

### **Attach Label to Record from Form Button (Server-side) -** Attach a barcode label to a record via a button click w/ server-side barcode generation:

1. Visit **Barcode & QR Code Generator -> UI Actions** in the left nav. Locate and open the UI Action titled 'Test Attach Barcode (Server)'.
2. Update the **Name** and **Table** fields to match the table where you wish to place the button that will open the page. Following the instructions in the commented code, update code values to accommodate your needs. Insert and Stay to create a new record.

{% hint style="info" %}
This option utilizes server-side barcode generation. The resulting file type is PDF.&#x20;
{% endhint %}

<div><figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2FUXMT1nQKZVVkqElpUAQb%2F068%202.jpg?alt=media&#x26;token=5ad82b6c-d3ea-4a6d-9e39-9a018aa84814" alt=""><figcaption><p>Attach from Form (Server)</p></figcaption></figure> <figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2FgEfBXPgkQ72lm0o5EEVI%2F063.jpg?alt=media&#x26;token=71a05bce-b79d-44f9-934e-dbd4469900a9" alt=""><figcaption><p>PDF Attachment</p></figcaption></figure></div>

### **Attach Label to Record from Form Button (Client-side) -** Attach a barcode label to a record via a button click w/ client-side barcode generation:

1. Visit **Barcode & QR Code Generator -> UI Actions** in the left nav. Locate and open the UI Action titled 'Test Attach Barcode (Browser)'.
2. Update the **Name** and **Table** fields to match the table where you wish to place the button that will open the Dialog box. Following the instructions in the commented code, update code values to accommodate your needs. Insert and Stay to create a new record.

{% hint style="info" %}
This option utilizes client-side barcode generation. The resulting file type is PNG.
{% endhint %}

<div><figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2FXPUDfjvcbp4ZIr1cS5Hj%2F068.jpg?alt=media&#x26;token=4aaab133-952f-487a-a98e-58420d920987" alt=""><figcaption><p>Attach from Form (Browser)</p></figcaption></figure> <figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2Fc0UyG08rEh0WgWqoV86s%2F062.jpg?alt=media&#x26;token=a284d28e-2dd4-42bf-9aa1-f879956d15a9" alt=""><figcaption><p>PNG Attachment</p></figcaption></figure></div>

### **Attach Barcode to Record from Form Button (Server-side) -** Attach a barcode part to a record via a button click w/ server-side barcode generation:

{% hint style="info" %}
This method attaches a **Barcode Part**, not an entire **Barcode Generator** label.
{% endhint %}

1. Visit **Barcode & QR Code Generator -> UI Actions** in the left nav. Locate and open the UI Action titled 'Test Attach Barcode Part (Server)'.
2. Update the **Name** and **Table** fields to match the table where you wish to place the button that will open the page. Following the instructions in the commented code, update code values to accommodate your needs. Insert and Stay to create a new record.

{% hint style="info" %}
This option utilizes server-side barcode generation. The resulting file type is PDF.&#x20;
{% endhint %}

<div><figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2FK5mLI5YXhE2vCC3sQ8qu%2F009.png?alt=media&#x26;token=9c8b8311-0717-4cf6-8764-3d16fca9604e" alt=""><figcaption><p>Attach from Form (Server)</p></figcaption></figure> <figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2F0erEnq87UOUEwTOLZCO1%2F010.png?alt=media&#x26;token=6a799847-f292-4dfe-b968-70db619fb402" alt=""><figcaption><p>SVG Attachment</p></figcaption></figure></div>

## From List:

### **Attach Label to Record from List Choice -** Attach barcode labels via a list choice:

1. Visit **Barcode & QR Code Generator -> UI Actions** in the left nav. Locate and open the UI Action titled 'Test Attach Barcodes (List)'.
2. Update the **Name** and **Table** fields to match the table where you wish to place the list choice. Following the instructions in the commented code, update code values to accommodate your needs. Insert and Stay to create a new record.
3. Visit the list view of the specified table, check as many options as desired from the list, and then click the specified UI Action from the drop-down menu. This will trigger an attachment of the barcode labels to the specified records.

<figure><img src="https://1867719272-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF2SazJJWf6DjyEIJAtF4%2Fuploads%2FI1XnjWiUw0dbAqwLnGge%2FScreenshot%202024-05-22%20at%209.08.55%E2%80%AFAM.png?alt=media&#x26;token=1e4eb216-47f1-4375-a130-adc695fa65bc" alt=""><figcaption><p>Attach from List</p></figcaption></figure>

{% hint style="info" %}
This option utilizes client-side barcode generation. The resulting file type is PNG
{% endhint %}
