Introduction to Triggers in Salesforce

Introduction to Triggers in Salesforce

If you are looking to build a powerful web or mobile application then Apex, Salesforce’s proprietary platform language, would be an ideal solution. 

Salesforce, one of the powerful and flexible CRM solution providers, offers the most powerful Force.com programming language known as Apex to help you create powerful business applications.

Apex in Salesforce

Apex is an object-oriented programming language that allows developers to execute flow and transaction control statements on Salesforce.com.

Apex Trigger in Salesforce is an Apex code that gets executed whenever a specific DML operation is performed on an Object record. It enables developers to programmatically check for duplicate records, update fields across objects, automate the creation of new records based on criteria, etc.

A trigger is an Apex script that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted.

A trigger is an Apex code that executes before or after the following types of operations like insert, update, and delete.

Two Types of Triggers

  • Before Triggers-Before triggers are used to execute a task before a record is inserted or updated or deleted. These triggers are used to update or validate record values before they are saved to the Salesforce database.
  • After Triggers-They are used to access values of the record that are stored in the database and use this value to make changes with other records. They get executed after the record is saved to the Salesforce database.

Bulky Trigger

By default, all triggers in Salesforce are bulky triggers. Bulky triggers define that you can process multiple records at a time. Bulky triggers can handle bulk operations and single-record updates such as:

  • Importing data
  • Mass actions
  • Bulk API calls
  • Recursive Apex methods and triggers call bulk DML statements

Trigger Context Variables in Salesforce

isExecuting: Returns true, if the current apex code is triggered. 

isBefore: Returns true if the code inside trigger context is executed before the record is saved.

isAfter:  Returns true if the code inside trigger context is executed after the record is saved.

isInsert: Returns true if the code inside trigger context is executed due to an insert operation.

isUpdate: Returns true if the code inside trigger context is executed due to an update operation.

isDelete: Returns true if the code inside trigger context is executed due to delete operation.

isUnDelete: Returns true if the code inside trigger context is executed due to undelete operation, i.e., when we recovered data from the recycle bin.

new: Returns the new version of the object records. If inserted/updated 10 records, trigger.new will contain 10 records.

newMap: Returns a map of a new version of sObject that contains an ID’s as a key and the old versions of the sObject records as value. This map is only available in before update, after insert, and after update triggers.

old: Returns the old version of the object records.

oldMap: Returns a map of the old version of the sObject that contains an IDs as a key and the new versions of the sObject records as value. This map is available for the only update and delete triggers.

size: Returns the size of the manipulated record. It will return one if you insert one record. It will return the size of the record you are inserting, updating, deleting, or undeleting.

Factors to consider when implementing Salesforce Triggers

Merge triggers are fired on both (insert and update) events on delete operation.

  • Upset triggers are fired on four different events such as before (insert and update) and after (insert and update).
  • Field history is updated after the trigger has successfully executed data and information processing.
  • A trigger cannot have a static keyword within its code.
  • Any callout should be asynchronous so that the trigger does not have to wait for the response.
  • If a trigger executes successfully then the changes are committed to the database and if it fails, the transaction is rolled back.

Syntax of Salesforce Trigger 

trigger triggerName on ObjectName (trigger_events) {

    //code_block

} trigger TestTrigger on Case (Before Insert,After Insert,Before Update ,After Update ,Before Delete ,After Delete,After Undelete) {

  //Code Block

 }

  1. Apex trigger always begins with a keyword trigger.
  2. Enter a Trigger name.
  3. Enter the condition.
  4. To execute trigger on a case like before insert, after insert, before the update, after the update, before delete, after delete, after undelete, you must specify the trigger event.

Conclusion

Salesforce Trigger is an Apex code that gets executed before or after inserting or modifying a record based on the specified condition. 

Triggers in Salesforce can be defined as the programmatic event handlers that get executed when a record is saved. They get executed when a DML operation occurs on a sObject record. Salesforce Triggers can handle Database manipulation language (DML) operations, execute Salesforce Object Query Language (SOQL), and call custom Apex methods. 

If you are looking to explore more about Salesforce triggers, feel free to reach out to certified Salesforce experts and specialists at Cloud Analogy, the world’s leading Salesforce Consulting Partner. Cloud Analogy offers a wide range of cost-effective Salesforce consulting services in UK including admin support, development, data migration, customization, and more. Choose the world’s leading Salesforce Consulting Company now!

Everything you need to know about Salesforce Data Loader

Everything you need to know about Salesforce Data Loader

Currently, Salesforce is the world’s leading CRM provider used for automating workflow processes and streamlining business operations. It provides a wide range of tools and functionalities to help us provide excellent customer service. To maximize the value of your Salesforce investment, you must use innovative tools of the CRM to update, migrate, and export data from Salesforce efficiently. One such robust and convenient tool in Salesforce is Data Loader.

What is Salesforce Data Loader?

In today’s digital age, proper analysis of data is crucial for making faster, better, and data-driven decisions. Effective data management is vital for organizations to analyze data, remove duplicate and inaccurate information, and maintain reliable data.

Data Loader is one of the most powerful tools that is used to quickly and securely import, export, and delete unlimited amounts of data within the Salesforce Org. This tool is generally available in both the Salesforce Classic and Salesforce Lightning Experience versions.

Data Loader tool ensures a smooth and efficient integration of new data into Salesforce as well as provides effective ways to reduce data redundancy. Users can use Data Loader in two different ways. They can either install the data loader in a Mac/Windows environment by using the user interface or by using a Windows command line to specify data files. 

Now let’s discuss what Salesforce developers and admins should need to know to make the most out of Salesforce Data Loader within their organization.

Features of Salesforce Data Loader

Insert: Provides the user the ability to insert data into Salesforce.

Update: Allow the users to make changes to existing records within Salesforce.

Delete: Deleting records from the system that aren’t required anymore.

Export: Enable the users to export information from the Salesforce in the CSV format.

Hard Delete: The delete option stores deleted data in the Recycle Bin for a limited period while Hard Delete will remove it completely.

Advantages of Salesforce Data Loader

The most exciting feature of Salesforce Data Loader is that users can load up to 5 million records at a time. Users can use the Data loader to prevent the creation of duplicate records according to the account name, contact email address, or other information in your Salesforce. Due to its seamless integration with the Salesforce platform, the Data loader allows the team members – from developers to admins – regardless of their expertise and specialization, to seamlessly work with the data loader.

The comprehensive data loader tool provided by Salesforce is designed for a large volume of records ranging from 50,000 to 5,000,000. It also provides users with the ability to save field mappings for further use instead of choosing the fields for mapping each time. In case, the user needs to load less than 50,000 records, the user can utilize Salesforce Import Wizard alternatively.

Ways to Use Salesforce Data Loader for Data Management

Intelligent Data Mapping  – Keyboard shortcuts and various filters are available to gain clear data visibility and targeted analysis. It is the process of mapping the user IDs accurately to ensure that the record ownership is set up correctly in the new system.

Import and export directly from multiple repositories – Exporting and importing are fast and easy with the Salesforce Data Loader as team members can import and export directly from SFTP, DropBox, FTP, and Box.

Windows/ MAC Support – Salesforce Data Loader offers support for Windows and Mac computers that means that if a company switches over from Windows to Mac computers or vice versa, then they don’t have to worry about not having support for Data Loader. 

Effective task scheduling – Effective scheduling is ensuring that you identify your most important task for each day and then you get those tasks completed. You should also identify the next couple of tasks in order of importance. By effective task scheduling, the users can also choose the task to be done on an hourly, daily, weekly, or monthly basis. 

Detailed error and success Logs – Salesforce Data Loader keeps detailed logs of all errors regarding importing and exporting of records, as well as other functions. It also keeps detailed logs of all the successful executed commands and all errors regarding importing and exporting of records, as well as other functions.

This makes it easier for those studying the logs to compare the rate of successful commands to the rate of unsuccessful commands.

Considerations for Using Salesforce Data Loader

  • Data Loader is supported for loading data up to 5 million records.
  • The user needs to load into an object or custom object that is not yet supported by the import wizards.
  • The user wants to schedule regular data loads like nightly imports.
  • The user wants to export the data for backup purposes.

Conclusion

Salesforce Data Loader makes data management easier and more efficient by importing and exporting large amounts of records in Salesforce.com. While importing data, Data Loader reads, extracts, and loads data from comma-separated values (CSV) files or via database connection. In the case of exporting data, it generates files in the CSV format. From powerful data mapping tools to seamlessly integrate new data into the system,  Salesforce Data Loader has got all the bases covered. 

If you have any questions about the Salesforce Data Loader, feel free to contact the certified Salesforce experts from Cloud Analogy today.

What are REST Web Services?

What are REST Web Services?

A REST (Representational State Transfer) resource is an abstraction of a piece of information or an action such as a single data record, a collection of records, or a query. Each resource in REST API is identified by a named Uniform Resource Identifier (URI) and accessed using standard HTTP methods (HEAD, GET, POST, PATCH, DELETE). REST API is based on the usage of resources, their Uniform Resource Identifiers (URIs), and the links between them.

You can use a resource to interact with your Salesforce org. For instance, you can perform actions such as:

  • Retrieve summary information about the Application programming interface (API) versions available to you.
  • Obtain detailed information about a Salesforce object, such as Account, User, or a custom object.
  • Perform a query or search.
  • Update or delete records.

A REST request consists of four components: a resource URI, an HTTP method, request headers, and a request body. Request headers specify metadata for the request. The request body specifies data for the request, when necessary. If there’s no data to specify, the body is omitted from the request.

Basically, Restful services are REST architecture based on Web Services. RESTful web services are lightweight, highly scalable, and maintainable and are used to craft APIs for web-based applications.

Benefits of Restful Web Services

Fast: RESTful Web Services are fast because there are no strict specifications like SOAP. It uses less bandwidth and resources.

Language and platform-independent: RESTful web services can be written in any programming language and run on any platform.

Can use SOAP: RESTful web services can use SOAP (Simple Object Access Protocol) web services as the implementation tools.

Allows various data formats: RESTful web service allows various data formats such as Plain text, HTML, XML, and JSON.

Apex REST Methods

Apex REST supports two formats for representations of resources: JSON and XML.

JSON representations are passed by default in the body of a request or response and the format is indicated by the Content-Type property in the HTTP header. You can retrieve the body as a Blob from the HttpRequest object if there are no parameters to the Apex method.

If parameters are defined in the Apex method, an attempt is made to deserialize the request body into those parameters. If the Apex method has a non-void return type, the resource representation is serialized into the response body.

These return and parameter types are allowed:

  • Apex primitives (excluding sObject and Blob).
  • sObjects
  • Lists or maps of Apex primitives or sObjects (only maps with String keys are supported).
  • User-defined types that contain member variables of the types listed above.

Methods annotated with @HttpGet or @HttpDelete should have no parameters. This is because GET and DELETE requests have no request body, so there’s nothing to deserialize.

A single Apex class annotated with @RestResource can’t have multiple methods annotated with the same HTTP request method. For example, the same class can’t have two methods annotated with @HttpGet.

Example:

You can use user-defined types for parameters in your Apex REST methods. Apex REST deserializes request data into public, private, or global class member variables of the user-defined type unless the variable is declared as static or transient. For example, an Apex REST method that contains a user-defined type parameter might look like the following:

@RestResource(urlMapping=’/user_defined_type_example/*’)

global with sharing class MyOwnTypeRestResource {

    @HttpPost

    global static MyUserDefinedClass echoMyType(MyUserDefinedClass ic) {

        return ic;

    }

    global class MyUserDefinedClass {

        global String string1;

        global String string2 { get; set; }

        private String privateString;

        global transient String transientString;

        global static String staticString;

    }

}

Valid JSON and XML request data for this method would look like:

{ “ic” : {

                “string1” : “value for string1”,

                “string2” : “value for string2”,

                “privateString” : “value for privateString” 

}}

Conclusion

REST stands for Representational State Transfer. REST is used to build lightweight, well-maintained and scalable web services. The main aspects of REST are the resources on the server and the verbs GET, POST, PUT, and DELETE which can be used to work with these resources. Visual Studio and .NET can be used to build Restful Web Services.

If you are looking for certified Salesforce developers or Salesforce implementation partners, Cloud Analogy — the world’s leading and most successful Salesforce Development Company — would be the right choice for you.

React Native vs. Flutter – Which is right for Your Cross-Platform App Development?

React Native vs. Flutter – Which is right for Your Cross-Platform App Development?

With the growing popularity of mobile applications, almost every business requires out-of-the-box mobile applications to stay competitive in the market. Therefore, businesses have started embracing cross-platform solutions instead of native solutions to craft iOS and Android applications faster, utilizing a single language.

You might have heard a lot of buzz about two cross-platform mobile frameworks — React Native and Flutter. 

React Native by Facebook and Flutter by Google are the two popular cross-platform app development technologies that are being used to build thousands of mobile apps today.

Both React Native and Flutter are currently very popular among developers who want to create high-quality and robust native applications for the Android and iOS operating systems, without spending much time and effort. 

Which one to choose-React Native or Flutter? 

This is a constant question that developers often try to solve. So let us help you make understand the differences between the two and also explore which works best for your project.

React Native vs. Flutter

User Interface

When it comes to application user interface and component creation, there is a huge difference between React Native and Flutter.

React Native makes the use of native user interface (UI) components that allow you to build your UI with isolated components or libraries. You can access a wide range of libraries that are updated on a regular basis. 

Flutter uses proprietary gadgets. They are similar to components and are easy to learn if you have some experience with the React or Angular components. 

Flutter offers you a larger set of user interfaces that could be what would make you choose it over React Native. 

Development Time

React native has remained one of the most trusted frameworks for developing the next generation of mobile applications. Because of its efficiency, it is highly preferred by the developers as it requires less time for project development.

Flutter development takes more time than React Native. The ready-to-use components of React Native speed up the development process, expanding the scope of mobile application development. 

Performance

Flutter vs. React native performance mapping is the best way to determine which framework is ideal for mobile application development. The reason why Flutter vs React Native stands out from another framework is due to the Dart (class-based, object-oriented language, and client-optimized programming language for fast apps on multiple platforms) framework. In addition, the JavaScript layers assist them to connect with native components easily.

Alternatively, React Native has a larger fan base and community. However, developers are aware of the problems they face when creating hybrid applications. However, native applications adapt well to these requirements. Under this framework, developers will not have any problems while developing applications in their native environment.

Developers sometimes experience problems using the React Native hybrid application architecture. While Flutter makes it easy for developers to reuse existing code, the C ++ engine works perfectly and supports language, which is why Flutter wins the battle hands down here!

Reusable Code

Both React Native and Flutter support reusable code that means developers can write the code once and use it on any other platform. This is what makes them a cross-platform framework. However, it is understandable that not all code can be easily transferred from one platform to another. Parts of the code can be reused and other parts need to be rewritten in a personalized way to fit the platform.

Flutter allows developers to easily rewrite pieces of code that need to be fixed to fit on the platform, making code reuse more effectively and precisely. This makes Flutter very useful for reusing code, making it a faster and more efficient framework.

React Native also allows code reuse, but with limitations. Only a few major components can be reused across platforms, while the rest must be written separately for each platform. Element styling and many other finer nuances must be adjusted manually which makes the process a little slower and tedious.

So, Flutter wins here again.

Documentation & Toolkit

Processing documentation is very complicated and time-consuming. However, Flutter is really very good at making documentation, simplifies the lives of mobile application developers, and allows them to use while documenting their applications. Therefore, Flutter is the best choice than its other competing frameworks in terms of documentation and tools.

The documentation process with React Native is not so managed and organized. In addition, the framework removes components that are useful to make the operation smooth. Therefore, it is clear that the tools bring strong competition between the two frameworks. Flutter has extensive IDEs and tools with React Native support. Visual Studio and Android Studio code compatibility improve the framework. Hence, Flutter is an appropriate winner here.

Final Wrap

As you might have noticed, React Native and Flutter have established themselves as effective and mature cross-platform frameworks. You can choose one of them and make a powerful application that works seamlessly on all major platforms. 

What’s important is what you’re compatible with. If you have experience with React or JavaScript, you will find that React Native is easy to learn. But if you are new, Flutter is a newer and clearer framework that would be worth a try.

Do you want to develop applications faster? Confused between React Native and Flutter for your application development project? Contact us and our Certified mobile application developers will help you create the perfect application for your business.

Differences between Salesforce Import Wizard and Data Loader

Differences between Salesforce Import Wizard and Data Loader

Today, Salesforce is a top-rated and most popular CRM used for transforming businesses across the globe. It provides a number of tools and functionalities to help us deliver the best and personalized service to the customers. In order to use Salesforce, one must know how to update, migrate and export data from Salesforce efficiently. There are a number of tools that Salesforce Administrations and developers can use to import data within Salesforce. These tools are available in both Salesforce Classic and Salesforce Lightning editions.

Import tools

Salesforce offers two main tools for importing external data into Salesforce.

Data Import Wizard – Salesforce provides an in-built Data Import wizard that is accessible through the Setup menu and can help you to import accounts, campaign members, person accounts, leads, custom objects, and contacts. This wizard is a step-by-step process that can take data to your desired location and displays error messages to change the potential duplicates of records.

It provides an easy interface and self-explanatory wizard to load the data into Salesforce. You can perform import operation from this wizard but delete and insert operations cannot be performed through this wizard. Data import wizard doesn’t allow to load the duplicate records and all fields can be individually mapped by this wizard within Salesforce.

Data Loader – Data Loader is the most efficient tool that is used to move data rapidly into the platform. The tool provided by Salesforce helps perform insert, update and delete operations on Salesforce records. It enables you to interact with your data within Salesforce across all objects. 

Data loader can help in various ways such as:

  • Inserting data from one system to another upon the initial implementation of Salesforce
  • Updating bulk records with new data
  • Deleting bulk records that aren’t required anymore
  • Exporting data to other systems 
  • Create a backup of previous data

In the process of data importing, Data loader reads, extracts, and loads data from Comma separated value (CSV) files or from database connections. While in the process of data exporting, the output is CSV files.

We can use Data loader in these two ways:

  1. Command line
  2. User Interface

Features of the Data Loader

  • Easy-to-use tool to offer a great interaction with data.
  • Command line interface for performing automated operations.
  • Support and manage the excess amount of data.
  • Drag-and-drop functionality is used for mapping fields.
  • It can be used to streamline data in both Salesforce and Database.com.
  • Error log files in CSV format.

Key Differences between Data Import Wizard and Data Loader 

Data Import WizardData Loader
For simple imports of dataFor complex imports of data
It can load up to 50,000 records.It can load up to 5,00,000 records.
It supports all the custom objects and only a few standard objects like Account, Contact, Campaign members, person accounts, Leads, and Solution.It supports all custom and standard objects.
It supports schedule export.It doesn’t support scheduled export.
Delete operation is not available. Delete operation is available.
Cannot import cases and opportunity.Can import cases, events, tasks, and opportunities
While importing, duplicates can be ignored.While importing, duplicates cannot be ignored.
It doesn’t require installation.It requires installation.

Things to follow before importing Salesforce Data

  • Use existing software for exporting a file.
  • Clean up the import file for data consistency and accuracy in order to update data to highlight the duplicates, remove unnecessary information, correct spelling and resolving errors.
  • Compare your data fields with Salesforce fields for importing data into it and verify that it can be mapped into suitable Salesforce fields. 
  • Perform any configuration changes if required in Salesforce to manage the imported data. Changes you might need to perform are:  create new custom fields, add new value to picklists, or deactivate workflow rules temporarily.

Steps to import Data using Data Import Wizard

Step 1: Login into Salesforce.

Step 2: From Setup, enter “Data Import Wizard” in the Quick Find box, then select Data Import Wizard.

Step 3: Click on the Launch Wizard button.

Step 4: Select the type of data that you like to import. Click on Standard Objects tab to import accounts, contacts, leads or Click on Custom Objects to import custom objects.

Step 5: Choose the operation you need to perform- To add new records to Salesforce, update existing records, or add new records and update existing ones. 

Step 6: Select the data file you want to import data

Step 7: Click Next. A page appears where you can map the data fields in the CSV file to Salesforce data fields.

Step 8: Click Map to the left of each un-mapped field.

Step 9: Choose the Salesforce fields you want to map to and click Map.

Step 10: To change the mappings, click Change to the left of the mapped field, then select the Salesforce fields you want to map to and click Map.

Step 11: Click Next.

Note: Check your imported information. If any un-mapped fields are still remaining that you want to import, you can click Previous to return to the previous page and specify your mappings.

Step 12: Click Start Import.

Note: You can see the status of your import- From Setup, enter “Bulk Data Load Jobs” in the Quick Find box, then select Bulk Data Load Jobs.

Insert, delete and update operations by Salesforce Data Loader

Log in to your salesforce

Go to setup-> Data management ->data loader

Download Data Loader in your machine.

To log in to the data loader choose any operation and log in by providing credentials. If you are log in to Production you need to provide “Password+security token” in the password field.

The main operations you can carry out with the Data Loader

Insert – Insert new records into Salesforce

Update – Make changes to existing records within Salesforce

Upsert – Updates a record if it already exists, or inserts a new record

Delete – Deletes records from the system

Hard Delete – Delete option stores information in the Recycle Bin for a limited period, Hard Delete will remove permanently

Export – Export information from the system into a CSV format

For Inserting records

Step 1: Click on the insert button and login with your credentials and provide “your org password + security token”.

Step 2: Click on NEXT 

Select the object you want to insert the records and choose the .csv file you want to upload.

Note: Data loader allow only .csv files.

Step 3: Map the fields using drag and drop features.

Step 4: Click on ok or save the mapping

Step 5: Click on NEXT and then click on Finish. 

After inserting the records it will display error files and success files.

For updating records

Step 1: Click on the update option and log in.

Step 2: Select the CSV file contains updated records with IDs and select the object and complete the operation.

For Exporting the data

Step 1: Click on the export button and login with your credentials.

Step 2: Select the object you want to export data and specify the folder where you want to save the exported file.

Step 3: Finish the operation.

For deleting the data

Step 1: Click on the delete button and login with your org credentials.

Step 2: Select the object you want to remove the data. And select the CSV files with record IDs you want to remove.

Step 3: Map the ID field and then complete the operation.

For Hard Delete

Hard delete means deleting the data permanently from the Org. That means data will not be stored in recycle bin. 

To enable this button you need to enable bulk API. To enable the bulk API button 

Go to data loader settings and then enable the bulk API checkbox.

After using Data Loader, a window will appear that will show the results about how many new records created, updated or deleted, depending on what operations you want to perform.

About Us

Cloud Analogy, a Salesforce development company, and a Salesforce consulting partner offers a wide variety of integration and development services to the end users as well as to the clients worldwide (India, UK, USA, and Australia). We offer high-quality and customized Consultation, Configuration, Implementation and support services using the latest tools and technologies. 

Feel free to contact us at www.cloudnalaogy.com

Pin It on Pinterest