---
schema_version: "1"
id: ee5172ccac62ec2201e34ca90791f5f56f63debd910349c83f83624f8e879b4a
title: Generate an Apex Class for a Context Definition
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/ctx_generate_apex_class.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.ctx_generate_apex_class.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 63c685f44b5d0afc52debe2ad522d88ad4b0861a5669d0b5db36480cd9c0a3b1
description: View definition-specific invocable actions in Salesforce Flow by generating Apex classes from your context definitions. The Apex classes mirror the metadata and hierarchy of your context definition, which can be used directly in Salesforce Flow without any coding required.
products:
  - Industry Solutions
  - Cross Cloud
release: "264"
---
# Generate an Apex Class for a Context Definition

View definition-specific invocable actions in Salesforce Flow by generating Apex classes from your context definitions. The Apex classes mirror the metadata and hierarchy of your context definition, which can be used directly in Salesforce Flow without any coding required.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Developer</strong>, <strong>Enterprise</strong>, <strong>Professional</strong>, and <strong>Unlimited</strong> editions for Industries clouds where Context Service is enabled</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d2643e74">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d2643e74 ">To generate Apex classes:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d2643e74 ">Context Service Admin</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d2643e74 ">To create a flow:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d2643e74 ">Manage Flow</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d2643e74 ">To invoke context service actions:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d2643e74 ">
              <p>Context Service Admin</p>
              <p>OR</p>
              <p style="margin-bottom:0;">Context Service Runtime</p>
            </td>

          </tr>
        </tbody>
      </table>

1. From Setup, in the Quick Find box, enter `Context Service`, then select **Context Definitions**.
2. Select the context definition for which you want to generate an Apex class.
3. Click Generate Apex Class.
4. To view the generated Apex classes
    1. From Setup, in the Quick Find box, enter `Apex Class`, then select Apex Class.
    2. Search for the API name of your context definition.

Once an Apex class is generated, it can’t be edited. To delete an Apex class, go to the context definition page and click **Delete Apex Class**.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_important.png)

Important Deleting Apex classes can break Flows that use them. Make sure to remove the associated classes from all your Flow elements.

To refresh the Apex classes of a context definition you have edited, go to the context definition page and click **Refresh Apex Class**.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_important.png)

Important When a custom context definition is updated, the associated Apex classes are not automatically updated. You must manually refresh the Apex classes.