I recently transferred a bunch of metadata from one Salesforce Organization Instance to another. To do this, I created a package that contained all the custom objects, web components, apex classes, profiles, etc. Then, using the SFDX extension for VSCode, I pulled this package down via:

sfdx force:source:retrieve -n MyPackage

This pulled down all the metadata I needed, so then I authorized this SFDX project with a new organization instance, and I uploaded this package into the new organization instance. This worked and everything was uploaded properly into the new instance.

The one issue I have ran into, however, is my profile's access to the custom objects. In this new instance, I am operating as the System Administrator, whereas in the old instance I was operating as a custom profile.

So, to fix this, instead of going field by field through the UI and giving field-level permissions to the System Administrator from the new Instance, I pulled down the System Administrator's profile via:

sfdx force:source:retrieve -m "Profile:Admin" 

After getting this metadata, I added fieldPermission metadata blocks for all my custom fields. Each block looks like this:


So I gave the System Administrator Read and Edit access to all of these fields. Now, when I look in Salesforce I can SEE the fields in the list views, but I can't see them in the details views and I can't edit them...

These seems really odd to me because

A) Even though I gave edit access to the System Admin, I can't edit them; and,

B) In the old instance, I never created custom layouts for these custom objects, the layout was just whatever was defaulted when the object was created, and I could see these fields in the details in the old instance, but not the new instance...

What can I do to get this to work correctly?

  • Did you also deploy page layouts from old instance? – kurunve Oct 11 '19 at 21:57

You'll need to copy the page layouts, too. When you create fields in the UI, by default, they get added to the top section unless you uncheck the boxes. However, in the API, the layout is not explicitly modified simply by creating a field. Try:

sfdx force:source:retrieve -m Layout -u oldOrgAlias
sfdx force:source:deploy -p force-app/main/default/layouts -u newOrgAlias

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.