0

Can anyone please share how to export Macro & It's instructions together and import them in another org? I'm using Salesforce dataloader tool.

1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Mar 10 at 16:14

1 Answer 1

1

There's the following objects to consider - you may not need all of them if you don't use any conditionals within your macros (ExpressionFilter & ExpressionFilterCriteria) or enable/use macro folders (Folder).

  • Folder
  • Macro
    • Represents a macro, which is a set of instructions that tells the system to perform one or more tasks.

  • MacroInstruction
    • Represents an instruction in a macro. An instruction can specify the object that the macro interacts with, the context or publisher that the macro works within, the operation or action that the macro performs, and the target of the macro’s actions

  • ExpressionFilter
    • Represents a logical expression that’s used to control the execution of macro instructions.

  • ExpressionFilterCriteria
    • Represents a condition in an expression that’s used to control the execution of macro instructions.

You can see the data model as such

enter image description here

You'll have to, unfortunately, export all those and make sure the new Ids for each inserted record is reflected in their lookups when you insert them, one object at a time.

If you're able to set it up - you can leverage SFDX Data Move Utility (SFDMU) to make the above much easier. You'd store all the queries in export.json and provide source/target orgs and it'll handle the export/import for you.

{
    "objects": [
        {
            "query": "SELECT Id, AccessType, DeveloperName,IsReadonly,Name,Type FROM Folder WHERE Type = 'Macro'",
            "operation": "Upsert",
            "externalId": "Id"
        },
        {
            "query": "SELECT Id, Description, FolderId, Name, OwnerId, StartingContext FROM Macro",
            "operation": "Upsert",
            "externalId": "Id"
        },
        {
            "query": "SELECT Id, MacroId, Name, Operation, SortOrder, Target, Value FROM MacroInstruction",
            "operation": "Upsert",
            "externalId": "Id"
        },
        {
            "query": "SELECT Id, ContextId, FilterConditionLogic, FilterDescription, Name FROM ExpressionFilter",
            "operation": "Upsert",
            "externalId": "Id"
        },
        {
            "query": "SELECT Id, ExpressionFilterId, FilterTarget, FilterTargetValue, Name, Operation, SortOrder FROM ExpressionFilterCriteria",
            "operation": "Upsert",
            "externalId": "Id"
        }
    ]
}

Then, a simple command would kick off the export from the source org and import into the target org

sfdx sfdmu:run --sourceusername mySource@local.org --targetusername myTarget@local.org


Otherwise, if you want to understand each step or have to do this manually:

Export

  • SELECT Id,AccessType, DeveloperName,IsReadonly,Name,ParentId,Type FROM Folder WHERE Type = 'Macro'

    • ParentId will point to whether this folder is nested - in which case you'll have to insert parent folders first before inserting the nested ones.
  • SELECT Id, Description, FolderId, Name, OwnerId, StartingContext FROM Macro

    • FolderId will point to the related folder the macro is under from above query
  • SELECT Id, MacroId, Name, Operation, SortOrder, Target, Value FROM MacroInstruction

    • MacroId will point to the related Macro in the other query
  • SELECT Id, ContextId, FilterConditionLogic, FilterDescription, Name FROM ExpressionFilter

    • ContextId will point to the related MacroInstruction in the above query
  • SELECT Id, ExpressionFilterId, FilterTarget, FilterTargetValue, Name, Operation, SortOrder FROM ExpressionFilterCriteria

    • ExpressionFilterId will point to the related ExpressionFilter record in the above query

Import

Now that you have data for all 5 objects. You want to do the following:

  • Insert parent Folder records
  • Save mapping of old Folder record Ids to newly inserted Ids
  • Update remaining Folder records' ParentId to point to new Id
  • Insert remaining Folder reports (and repeat as necessary)
  • Save mapping of old Folder record Ids to newly inserted Ids
  • Update Macro ParentId to point to new Id
  • Insert Macro
  • Save mapping of old Macro record Ids to newly inserted Ids
  • Update MacroInstruction MacroId field in csv to point to new Id
  • Insert MacroInstruction
  • Save mapping of old MacroInstruction record Ids to newly inserted Ids
  • Update ExpressionFilter ContextId field in csv to point to new Id
  • Insert ExpressionFilter records
  • Save mapping of old ExpressionFilter record Ids to newly inserted Ids
  • Update ExpressionFilterCriteria ExpressionFilterId field in csv to point to newly insert Ids
  • Insert ExpressionFilterCriteria records

1
  • +1 great answer; also vendor alternatives to SFDMU like Prodly or Gearset
    – cropredy
    Mar 10 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.