Salesforce provides two relationships known as one to many relationship and many to many relationship(this can be done using junction object).
Sometimes we need to establish one to one relationship between two objects, since salesforce doesn't have any direct methodology to build one to one relationship.
Here are a few ways to implement one to one relationship between two objects in salesforce,
Create a Lookup field on two custom objects Employeid__c to Employe__c.
Which creates a relationship that links one object to another object. This field allows users to click on a lookup icon and select a value from the popup list. The selected object is source of the values in the list.
Here, we created lookup field between Employeid__c to Employe__c.
Create a custom field on the Employeid__c object, make this field unique (by using custom field we can hold the id of the associated employe__c).
Create a workflow rule on Employeid__c, then update the value of custom field.
Workflow rules can automate tasks, email alerts, field updates based on the organization requirement.
Here, we used workflow rule to update the value of field.
Create a Roll up summary field on custom object like numberofemployes__c by using count.
A field that displays the sum, minimum or maximum value of a field in a related list or the record count of all records listed in a related list.
In this, we used numberofemployees__c as custom object and roll up type as count.
Create a trigger in Employee object to check whether the number of employees is equal to one. If it is one, then throw an error, else allow the user to create new Employeid__c.
Apex triggers enable you to perform custom actions before or after changes to records such as insertions, deletions and updates.
In this trigger is used to run before the new Employeid__c is created so that it checks whether the number of employees euals to one or not.
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.
Django-CRM :Customer relationship management based on Django
Django-blog-it : django blog with complete customization and ready to use with one click installer Edit
Django-webpacker : A django compressor tool
Django-MFA : Multi Factor Authentication
Docker-box : Web Interface to manage full blown docker containers and imagesMore...