0

I want to add a custom field to all my salesforce objects, at the same time, a high level idea, is that they are control ID for an external source, but is there a way to add the fields to all objects in the same edit?

1

I am not really sure what do you mean by the same edit, I am guessing you want to avoid doing this repetitive task, the best way to achieve this is using ANT, this video is abit old but it is quite good to start ANT Deployement

using ANT you will be able to copy and paste the metadata of the field into the object files, and then in 1 deploy it sends all this in go hit, but it could take some time to get use to this. plus you will need to install JAVA in your pc. and what will make a bit trickier is the profiles, when you deploy with ANT you will need to also deploy profiles if you want this fields visible, otherwise you have to go to the back end 1 by 1 and ammend this. This is a link for the salesforce ant docs it is pretty good too:

ANT Salesforce doc

Probably 2 good alternative but still is a 1 by 1, but a lot smoother and faster is using this website it makes field creating a breeze https://fieldcreator.herokuapp.com/

or the schema builder from set up

0

You would need to do this using the Metadata API by performing a deployment.

You can use the Force.com IDE or another Salesforce IDE to generate a package.xml to extract all of the objects from your org. (You can also construct this by hand - the entity you want is CustomObject - but you'll need to list all your standard objects individually as the wild-card entry doesn't include them).

Once you've extracted the metadata, just locate an existing field of the type that you want to create to use as a template (simply because it's easier), or build one by reference to the CustomField Metadata API entity. You can then paste that XML entity within the body of each object you extracted, and use the same Metadata API tool you started with to perform a deployment and place those new fields in Salesforce in a single operation.

As an example, the metadata for a text field might look like this:

<fields>
    <fullName>My_Field__c</fullName>
    <externalId>false</externalId>
    <inlineHelpText>Used to store some data.</inlineHelpText>
    <label>My Field</label>
    <length>80</length>
    <required>false</required>
    <trackFeedHistory>false</trackFeedHistory>
    <trackHistory>false</trackHistory>
    <type>Text</type>
    <unique>false</unique>
</fields>

and could be independently added to many different custom object metadata files.

You could do something similar using Salesforce DX. While the metadata source format differs, the principle is the same.

0

SFDX is the new powerful tool to that you need. Combine it with Visual Code Studio for IDE and your life will become easier. While Force.com IDE and ATN are sufficient to that job too, SFDX and VSC are the new way promoted by SF.

Here is the trail that is 1000% worth it. Also you might want to check here where it is explained how to add a field

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.