Posts

Showing posts with the label ApexCode

How to create Salesforce Object with Code(MetadataService Class)

Image
  #SalesforceOhana #Object #ApexCode #CreateSalesforceObjectThroughCode #Coding  What are Salesforce Objects? => Salesforce Objects are database tables in which we can store our data to a specific organization. In Salesforce, we have two kinds of Objects. Standard Object :- The Objects which are already made by Salesforce itself. Forex. Account, Contact, Opportunity, etc. All are Salesforce Standard Objects. Custom Object :- The Objects which are made by the User itself. Can you create Salesforce Custom Object through Code? => The answer is Yes, you can create Objects through Code. But, for this, you must have a MetaDataService Class in your org. Here is a link,  MetaDataSerivce Class . Let's see how we can. MetadataService.MetadataPort service = new MetadataService.MetadataPort();           service.SessionHeader = new MetadataService.SessionHeader_element();         service.SessionHeader.sessionId = UserInfo.getSess...

Create Validation Rules Through Code

Image
  #Salesforce #ValidationRules #ApexCode #CreateValidationRulesThroughCode What is the Validation Rule in Salesforce?  Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False” Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value Can we create a Validation Rule through code? => The answer is yes. We can create a validation rule through code. But, for this, you must have a MetaDataService Class in your org. Here is a link,  MetaDataSerivce Class . The code is given below to create the Validation Rule:- MetadataService.MetadataPort service = new MetadataService.MetadataPort();         service.SessionHeader = new MetadataService.SessionHeader_element();   ...