---
title: "Actions in FieldBuddy Swift"
canonical: "https://help.fieldbuddy.com/space/FBDOCS/4921393153/Actions%20in%20FieldBuddy%20Swift"
format: markdown
---
> ℹ️ Actions are supported both in FieldBuddy Classic (discontinued) and FieldBuddy Swift!

## What are Actions in FieldBuddy

Actions (`FIELDBUDDY__Action__c` object) allows you to perform various actions with your FieldBuddy mobile application users, such as -- **Hard Reset** (mobile application sync all data and gets most up to date config and metadata changes, such as picklist values), **Message** (shows message to technician) or **Backup** (allows to report internal state of mobile application in order to do troubleshoot of issues).

Action is a regular salesforce object that can be created manually or via automations. Check example below  


![image](media://65c62ff4-020d-40dc-8eed-a983b42af307)

Important notes about action:

1. `Target` is required. That one allows to specify an mobile app that is being used (Mobile for FieldBuddy Classic or Swift for FIeldBuddy Swift)
2. Scheduled date can be in the future (or a bit in the past).
3. The actual date of action run will be always AFTER scheduled date, when app is opened and performed as sync  
For example, you schedule a Hard Reset action for technician for today, and he will only open Swift app in 3 days. Then action will be executed in those 3 days.
4. Data field. Field can be specified for action with type Message for FieldBuddy Classic (just in plain text) and in JSON format for Hard Reset and Message types for FieldBuddy Swift. Format of message is following:

## Action Types

Below are supported action types in FieldBuddy Swift

> 📝 Please note that Message is not supported in FieldBuddy Swift!

| **Action Type** | **Description** | **Supported** |
| --- | --- | --- |
| **Hard Reset** | FieldBuddy sync all data and gets most up to date config and metadata changes, such as picklist values | FieldBuddy Swift, FieldBuddy Classic |
| **Relaunch** | Restarts FieldBuddy Swift app – and also updates a Swift App if there was new version published via developer (does not update automatically if an update is published via an AppStore or Playmarket) | FieldBuddy Swift |
| **Backup** | Allows to report internal state of mobile application in order to do troubleshoot of issues | FieldBuddy Swift |
| **Message** | Shows certain message to technician | FieldBuddy Classic |
| Report Problem |  | FieldBuddy Classic |
| Clear History Table |  | FieldBuddy Classic |
| Soft Reset |  | FieldBuddy Classic |

## When to use actions

1. If there are various Configuration changes (for Swift or Classic) → **Hard Reset **is required in order to pick it up. An equivalent of that is Logout and Login (but it will require user password re-entering. Actions do not require it)
2. If There are metadata changes (for example, new field added or picklist value changed)  → **Hard Reset** is required in order to show it in FieldBuddy Swift
3. If users should be informed about some maintenance in advance → **Message** action can be used
4. If user experience issues – **Backup** action can help to check list of steps/recover missing data

## How to create an Action

There are Few ways ways to create actions - either manually or via Configuration panel (since FieldBuddy  1.145.0).

It is also possible to do it via apex snippet - check for the example below.  Preferred way would be to use Configuration Panel

### Actions via Configuration Panel

Go to Configuration Panel → Setup FieldBuddy Swift → Actions  
(More about Configuration Panel here -> [https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5365268532](https://upperdeck.atlassian.net/wiki/spaces/FBDOCS/pages/5365268532) )

From there you can select in convenient way type of an action, for who to dispatch it and for when.

![image](media://146e5dd9-a81d-47a8-915b-282f05fa5d3c)

It only supports FieldBuddy Swift actions. In case if you created Actions by mistake – you can also delete all Open Swift actions and re-created it again

### Manual way to create action

1. Go to **Actions** tab
2. Click **New** button
3. Specify Status as Open, Target, Type, Data, pick User and set Scheduled At date
4. Click Save. Completed

## What to do if actions should be created for all Users

It is possible use following snippet to schedule an action for all users that have FieldBuddy license assigned, ( `Hard Reset` for FieldBuddy Swift mobile application with message `Onderhoud` and it will be scheduled in 4 hours from now). 

This can be executed in Developer Console in Execute Anonymous action  


```
String message =
  '{'
+'"Message":"Onderhoud...", '
+'"Success" : "Onderhoud voltooid!"'
+'}';
DateTime dateOfExecution =  DateTime.now().addHours(4);
List<User> users = [SELECT id, Name, IsActive, Profile.Name
                    	FROM User
                    WHERE Id in (
                    SELECT UserId
                     from UserPackageLicense
                      WHERE PackageLicense.NamespacePrefix = 'FIELDBUDDY')
                    AND IsActive = true];
List<FIELDBUDDY__Action__c> actions = new List<FIELDBUDDY__Action__c>();
for (User user : users) {
    FIELDBUDDY__Action__c action = new FIELDBUDDY__Action__c();
    action.FIELDBUDDY__Status__c = 'Open';
    action.FIELDBUDDY__Type__c = 'Hard Reset';
    action.FIELDBUDDY__Data__c = message;
    action.FIELDBUDDY__Scheduled_at__c = dateOfExecution;
    action.FIELDBUDDY__Target__c = 'Swift';
    action.FIELDBUDDY__User__c = user.Id;
    actions.add(action);
}

insert actions; 
```