Wiki

Clone wiki

IlluminatedCloud / User_Guide / Creating_Metadata

[Home]

Creating Metadata

You can create metadata in your local project, then use Illuminated Cloud to deploy it to your connected org.

The process you use to do so depends on whether your project is configured to use the traditional metadata format where the source file must reside under its metadata-specific directory (e.g., Apex classes under classes folder, Visualforce components user components folder, etc.) or the Salesforce DX source format, which offers more flexibility in how you can structure the metadata within your project. For more information about the capaibilities and limitations of source format project organization, see Salesforce DX Project Structure and Source Format.

Illuminated Cloud supports first-class creation of the following Developer-oriented metadata types:

Out-of-the-box file templates are provided for the bodies and headers for each of these metadata types. Select Preferences > Editor > File and Code Templates to view and customize file templates:

metadata_templates.png

For more information about customizing and authoring file templates, see JetBrains' File and code templates documentation.


Creating Developer-oriented Metadata Types

To create new files for first-class supported developer-oriented metadata types:

  1. Navigate to the appropriate directory in your project based on the type of metadata you wish to create.

  2. Right-click to display the context menu and select New > the specific type of metadata you want to create.

    NOTE: To help you keep your project source tree consistent with the format of the project, Illuminated Cloud limits the available options to only those that correspond to where you initiate the right-click menu — the current context. For example, if you right click on the top-level folder of your project, all relevant object types are listed. If you right click on the classes folder in a metadata format project, only the Apex Class Salesforce-specific metadata type is listed. As noted previously, source format projects support a more flexible project directory layout and options for creation are limited only for those metadata types for which a specific directory structure is required.

    metadata_context_menu.png

  3. Enter all information required to create the new metadata object. This may be as simple as a name or it may require additional details to be provided for more complex types such as Apex triggers, static resources, or Lightning Web Components. If the metadata type supports multiple templates, choose a template from the presented options.

    Apex Class

    When creating a new Apex Class, you’ll need to specify a unique class name and choose a template from which the new class will be generated:

    metadata_new_apex_class.png

    Apex Trigger

    When creating a new Apex Trigger, in addition to a unique name you’ll also need to specify the SObject upon which the trigger will react as well as the events to which it will react:

    new_apex_trigger.png

    Visualforce Page/Component

    When creating a new Visualforce Page or Component, you’ll only need to specify a unique name for the new object.

    new_VFC.png

    Static Resource

    When creating a new Static Resource, you’ll need to specify a MIME Type so both the associated org and the IDE know how to handle the resource. You may also specify an optional description and set the cache control policy:

    new_static_resource.png

    If an archive-type MIME type is specified, specifically application/zip, the static resource is automatically treated as a resource bundle in source format projects or can be converted to a resource bundle in metadata format projects. Static resource bundles allow you to work with the contents of archive-type static resources directly. This is very useful when bundling multiple related files together for reference from Visualforce or Lightning markup.

    Aura Bundle

    When creating a new Aura bundle, you’ll need to choose the type of bundle to create, Application, Component, Event, Interface, or Tokens. All files required for the selected bundle type will be created automatically.

    new_aura_bundle.png

    Additional bundle files which are appropriate for the bundle type, e.g., Helper, Controller, etc., can be added later using the IDE's file creation capabilities. Illuminated Cloud will only present options for bundle files which are appropriate for the current bundle type and not yet present:

    new_aura_bundle_file.png

    Lightning Web Component

    When creating a new Lightning Web Component, you’ll first need to specify the type of component:

    • UI - for components related to app presentation
    • Modal - for modal dialog components
    • Service - for components containing only JavaScript logic
    • Style - for components containing only CSS style information

    new_lwc.png

    You’ll then need to specify a unique component name. An ES6 class name and display name will be automatically generated based on the component name, though both can be customized if desired. You can also specify whether the component is exposed to the App Builder and whether you wish to include a CSS file in the initial component. If you do not choose to create a CSS file at this time, you can add one to the component later using the IDE's file creation capabilities.

    Illuminated Cloud only presents options for adding component files which are appropriate for the current component type and not yet present:

    new_lwc_component_file.png

  4. Illuminated Cloud creates the new object based on the associated template, along with the corresponding meta.xml file if appropriate and — depending on how you’ve configured the IDE to respond when files are added or removed from a project — prompts you to choose whether you want to update your metadata subscription to include the new metadata.

    update_metadata_prompt.png

    NOTE: If your project is associated with a version control repository, and you've configured it to prompt you on file create operations, you’ll also be prompted to choose whether you want to add the new files to version control. If you’ve configured it to automatically add new files to version control, it will do so without prompting you.

  5. If you chose to update your metadata subscription, you’ll see a notification when that process completes. If you’ve enabled the Deploy on save option, Illuminated Cloud automatically deploys the new files to the associated org and updates the status bar to notify you when the operation has completed successfully.

    update_metadata_deployed.png

  6. The new source file is listed in the project’s source tree, along with its associated metadata:

    new_file_metadata.png


Creating Other Metadata Types

If you have an existing metadata object in the project that’s similar to the one you want to create, you can use it as the basis for the new file.

For example, let's assume you have existing field metadata for the amount of an expense in a source format project:

objects/Expense__c/fields/Amount__c.field-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>Amount__c</fullName>
    <description>The expensed amount</description>
    <externalId>false</externalId>
    <label>Amount</label>
    <precision>18</precision>
    <required>false</required>
    <scale>2</scale>
    <trackTrending>false</trackTrending>
    <type>Number</type>
    <unique>false</unique>
</CustomField>

Now assume that you want to add a new field to represent the reimbursed amount for the same expense.

Select the object in the project tree and select File > Copy (or use the F5 keyboard shortcut), give the new file a unique name (e.g., ReimbursedAmount__c.field-meta.xml), and click OK.

The IDE creates the new file for you, populating it with the contents of the original file you copied. If configured to do so, Illuminated Cloud will also automatically add the new field to your metadata subscription.

You can then customize this new field which was created from a similar field instead of having to create it from scratch. In this example, you'd change the values for fullName, description, and label to reflect the nature of the desired new field:

objects/Expense__c/fields/ReimbursedAmount__c.field-meta.xml

<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>ReimbursedAmount__c</fullName>
    <description>The reimbursed amount</description>
    <externalId>false</externalId>
    <label>Reimbursed Amount</label>
    <precision>18</precision>
    <required>false</required>
    <scale>2</scale>
    <trackTrending>false</trackTrending>
    <type>Number</type>
    <unique>false</unique>
</CustomField>

Now you're ready to deploy or push the new field to your organization, check it into your version control system, and continue working.

[Home]

Updated