Adding custom fields to your custom object in Salesforce

After creating your custom object, you can add custom fields and relationships with other objects to enhance the information that appears on that object.

By default, all custom objects are given a unique identifier (UID), which is the string used to run queries and return data for that object.

Objects must have a custom Name field, which you need to add. Name is the natural key for an object and is used to display a record in all cases beyond standard objects. An object without a Name field cannot be used in a Lookup Relationship with another object, as the record is not easily recognizable.

The Name field can be a string or number data type. In Salesforce, you have the option to create a Name field with the Auto Number data type, which provides an incrementing number with an optional custom prefix for each object that you create.

To add a name field to an object, do the following:

  1. In the Object Manager for the Vaccine object, click Fields & Relationships in the left-hand menu. A page showing the fields that are currently set on the Vaccine object displays.
  2. Click New in the upper-right corner.
  3. Select the field type for the custom field you want to create. For this example, select Auto Number from the list of data types and then click Next.
  4. In the Field Label text box, enter Name. This is pre-populated in the Field Name field.
  5. Add a Display Format for your Name custom field. The format uses a prefix followed by an automatically generated number. As this is a custom field for the Vaccine object, this example will use the format VAC-{0000}.
  6. Type 0 in the Starting Number field and then click Next.
  7. Select the field-level security settings that you require and then click Next. Depending on your use case, it may make sense to add multiple fields. For the Vaccine object, it could make sense to add Brand and Number of doses fields.
  8. Click Save.

Creating relationships between custom objects

In our example use case, we would want vaccine records to be associated with jobs. To connect these two objects, you can use a custom field with a lookup relationship type. There could also be a requirement for a Supply object to provide the availability of a vaccine at a site. The Supply object could include fields such as Location or Count for ordering and record-keeping purposes. To achieve this, the same type of lookup relationship can be created between Vaccine and Supply objects as a field.

To add lookup relationships between custom objects, do the following:

  1. In the Object Manager for the Vaccine object, add another field with the data type: Lookup Relationship and then click Next.
  2. Select the Jobs object from the Relates To objects picklist, and then click Next.
  3. Click the Required text box and then click the option Don't allow deletion of the lookup record that's part of a lookup relationship. This makes the field mandatory and protects the connection between the two objects.
  4. Select the relevant security settings and click Next and then Save.
  5. Create a Supply object with a Name field in the same way you did for the Vaccine object.
  6. Add another field with the data type: Lookup Relationship, then click Next.
  7. Select the Vaccine object from the Relates To objects picklist, and then click Next.
  8. If you want the field to be mandatory, click the Required text box and then click the option Don't allow deletion of the lookup record that's part of a lookup relationship.
  9. Click Next.
  10. Select the relevant security settings and then click Next.
  11. Click Save.

Remember that objects and fields must be mapped in the Skedulo web application before they can be used in web extensions. For more information about mapping custom fields in the Skedulo web application, see Mapping custom objects and fields and Admin Settings: Custom Fields.