Salesforcesfdx

Notes on taking Production Metadata and releasing as an unlocked Package via GitLab (Part 1)

At a high level the steps are:

  • Create a sfdx project
  • Pull down metadata from production
  • Create scratch org from new metadata
  • Create GitLab integration
  • Push unocked package to production via UAT sandbox

Open prompt at where you want to initialise an sfdx project (command below will create the base directory called ProjectName.

sfdx force:project:create --projectname ProjectName --template standard

Open vscode and open the new folder created (my project is called HighwaysConcern

Note at the bottom of vscode there is no default Org Set

Next step is to connect to the production org that has the required metadata that we need to pull down. Click on ‘No Default Org Set’ and select the org that you want to connect to. If the org is not shown, open the command palette and enter sfdx: authorize an org.

The name of the org will appear on the bottom toolbar and a cloud will appear down the left hand menu

When this is clicked then the org is shown and all the available metadata is shown. Against each entry is a Cloud download icon. Move through the folders and pull down the content that you need. If this is complex with lots of dependencies then setting up a change set in the org will allow you to see dependencies. As information is downloaded then the folders in the force-app directory are added.

The next task is to create a scratch org and push the content that has been downloaded into this blank scracth org. This will show if the right dependencies have been downloaded.

Create the scracth org inside vscode terminal (or a command prompt in the main directory). Enter your own ScratchAlis as this is the name of your scratch org. -d 5 gives 5 dyas ofr the scratch org (canbe up to 30)

sfdx force:org:create --setdefaultusername --setalias ScratchAlias --definitionfile config/project-scratch-def.json -d 5 -s

At this stage the toolbar will now show the new scratch org and the cloud icon will be removed from the left toolbar. It is fine to switch between the scratchorg and the production org by clicking on the name of the org on the toolbar (this is likely needed soon).

Try and do a push of the content from your local vscode to the scratch org.

sfdx force:source:push

At this stage there are likely to be errors that need to sorted. This area can be complex and google is your friend plus the metadata documentation in Salesforce documentation. When the content has been push then the scratch org can be opened, either click on the Open icon (to the left of the org name)

sfdx force:org:open

At this stage we are ready to move to linking the project to GitLab. Continued in Part 2….

Leave a Reply

Your email address will not be published. Required fields are marked *