Skip to content

Tools for programmatically managing Salesforce metadata.

License

Notifications You must be signed in to change notification settings

pkozuchowski/salesforceTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Salesforce Tools

Tools for programmatically managing Salesforce metadata (currently only Profiles and PermissionSets).

Loading Profiles:

By Path

Profile p = new Profile("...my-project\\force-app\\main\\default\\profiles\\Admin.profile-meta.xml");

By Folder

    Profiles.fromDirectory("...my-project\\force-app\\main\\default\\profiles")

Modifying Profiles

Profiles.fromDirectory(profileDirectory)
    .forEach(p -> {
        p.add(new ApplicationVisibility("Application", true, true));
        p.add(new FieldPermission("Account.Custom_Field_1__c", true, false));
        p.add(new FieldPermission("Account.Custom_Field_2__c", true, true));
        p.add(new ObjectPermission("Custom_Object__c", true, false, true, true, false, false));
        p.add(new TabVisibility("Application_Log__c", TabVisibility.DefaultOn));
        p.saveFile();
    });

Removing XML nodes by predicate

Profiles.fromDirectory(profileDirectory)
    .forEach(p -> {
        p.remove((MetadataNode node) -> node.getMetadataName().contains("trailheadapp__"));
        p.saveFile();
    });

Merging Profiles

Merge will take all permissions from one profile and apply it onto another without creating duplicates.

Retain only those permissions that are available on another Profile

retainSamePermissions() accepts another Profile which will serve as a base and strips all permissions that are not listed on base profile. The goal is to streamline target profile to have the same set of permissions as base profile.

Profile p = new Profile("...my-project\\force-app\\main\\default\\profiles\\Dealer Agent.profile-meta.xml");
p.retainSamePermissions(new Profile("...my-project\\force-app\\main\\default\\profiles\\Dealer Supervisor.profile-meta.xml"));
p.saveFile();

About

Tools for programmatically managing Salesforce metadata.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages