---
title: "How to add a Custom Label to FieldBuddy Swift"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/5155782778/How%20to%20add%20a%20Custom%20Label%20to%20FieldBuddy%20Swift"
format: markdown
---
> Macro (toc)

# Intro

In this guide, I’ll explain how you can create your own “**Custom Label” ** and show it in **FieldBuddy Swift**. For the example i’ll use below, we will continue somewhat on where we left off in [this](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5155061777) guide.

Use case: On the Work Order Closure screen

When a technician sets the **closure status** of a “**Work Order = Follow_Up”** then the technicians needs to see a pop-up when (s)he tries to save the Work Order without filling in the required field. See example below:

![image](media://05374e3b-af13-4696-8a6e-278f8fb42eca)

> ⚠️ In this guide, you will need **System Administrator** permissions for your organization to complete the steps below.

## \uD83D\uDCD8 Instructions

> ⚠️ To complete the steps in this guide, **you’ll **need a “**Sandbox / Partial Copy”** of the production environment. You’ll need to edit an** “Apex-class”**, which you cannot do in your production Environment. Therefore, complete all listed steps below **first** in your **Sandbox** and then push your changes with a** “change set” **to your production environment!

> ⚠️ It’s highly recommended to refresh the Sandbox / Partial before you start making your changes to ensure you have the latest metadata in your Sandbox.

> ℹ️ Some data, shown in the screenshots below, might not exist or be different in your environment. So just follow along.

Remember this line of code in [this](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5155061777) guide:

```json
"alertMessage": "${Label.ToDoOnFollowUp}",
```

We will be focussing on creating this label, adding it to the Apex Class, pushing it to production and add it to FieldBuddy Swift if you haven’t done that already.

1. Login to the Sandbox of your environment at [https://test.salesforce.com](https://test.salesforce.com)
2. Navigate to the setup through the gear icon in the right upper corner and type in “custom labels”
3. Click **“new custom labels”**
  
4. Fill in the required fields
  Even though you are able to push the translation of your newly created label with change sets, I would recommend against it. I would only do this when you’ve recently refreshed your Sandbox. My advice would be creating the translation in your production environment.
5. Through Setup navigate to** “Apex Classes”** and search for the class called: **‘cls_CustomLabelsServiceWorker’**
  
6. Edit the class (picture below shows default class from TSO5).
  Add your line of code to the apex class and make sure to append the previous line with a ‘**,'** otherwise you’ll get a Syntax error.
  Save the class if you’ve made the requested changes
7. Update the unit test class **test_CustomLabelsServiceWorker** to match your change. This test asserts the total number of labels returned by `getExtraLabels()`, so every time you add (or remove) a custom label in the Apex class, bump the expected count in `testCallLabels` accordingly — otherwise the test will fail.
  Save the updated test class, and include it in the change set alongside the Apex class and custom label so it deploys together in the following steps.
8. Navigate to **“outbound change sets”** through the settings menu and create a new outbound change set
9. Give your outbound change set a name and description, if needed.
  
10. Now you have to add your components (the apex classes and custom label) to your change set. And in a later step the correct profiles who need access to the components.
  Add the custom label and the Apex Classes (including the test class) to the change set.
  
11. Add the correct profiles to your change set.
  By default you’ll choose **all FieldBuddy **Profiles** **and the **System Administrator **Profile
  
12. Your change sets should look something like this:
  Upload your change set to your production environment if you are happy and login to the production environment.
13. Through setup navigate to** “inbound change sets”**. Always **‘Validate’** your change set first **before** '**deploying'** it to your production environment.
  
14. When your deployment is successful, you’ll have to add the translation on the production environment to your custom label field (if you haven’t done that already in the sandbox **AND **if you pushed those changes with the** “Language Translation”** component)
  
15. On the production environment, navigate to the custom labels through setup and find your added custom label.
  Press **‘New’**, add the desired text in** “translation text”** and pick the language. And press Save.
16. Add the Custom label to your config, so it can be used in FieldBuddy Swift check [this](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5155061777) page for a refresher. Update the config and force a hard sync by logging out from FieldBuddy Swift and back in.
17. **Always** check the FieldBuddy Mobile Profile if it still has the Apex Class: cls_CustomLabelsServiceWorker assigned to the profile.

> ℹ️ When you validate your configuration there should be no missing labels anymore because you’ve asssigned the apex class to the FieldBuddy Mobile User. As shown in the below screenshot

![image](media://4cf14701-1d46-4698-8237-234554a52ba3)

## End result

 

![image](media://62529c6c-adfd-4fee-81f2-ff0b67a631a5)


## \uD83D\uDCCB Related articles



> Macro (contentbylabel)