Saturday, 27 March 2021

Trigger Scenarios in Salesforce

 In Salesforce, Triggers are known as Apex Triggers. The triggers are unique and are accessible, particularly for general and anticipated actions such as lead conversions. Trigger in the Salesforce is the Apex code that we use to perform the operation before and after we report the record. In this article, we will study different kinds of Trigger scenarios in Salesforce.

If you would like to become a Salesforce cpq training certified professional, then visit onlineitguru - A Global online training platform: “ Salesforce Certification Training” Course. This course will help you to achieve excellence in this domain.

Important Points for Trigger Scenarios

1. As per the execution order, we have two types of triggers: 1) before trigger 2) after the trigger.

  • Before the Insert Event
  • While using this event, we execute the code block before we insert a new record.
  • Data committed to the database.
  • After the Insert event

While using this event, first, we will execute the code block, and after that, we insert the record.

2.We use the Before trigger to perform the logic on the same object.

3.We use the “before event” trigger if we have to update the same record in the trigger.

4.In the Before trigger, the records are not committed to the database. Therefore, we skip the DML.

5.When the record is committed to the database, i.e. record Id is created, and our trigger records in read-only mode. We cannot update the values for more salesforce cpq learning path.

[Related Article: "How to create Sample Apex Triggers in Salesforce"]

Keywords of Trigger Syntax:

  1. Trigger name: It is the name that we have to give to our trigger.
  2. Object name: It is the object over which we have to perform the action.
  3. Trigger_events: They are the events list separated with commas. 

Real-Time Trigger Scenarios in Salesforce

Scenario 1:

Create “Sales Rep” with data type on Account object. While we create account records, account owners will be systematically inserted into the sales representative field. While we update the record account owner, the sales representative will be systematically updated.

Description:

In the upper trigger scenario, we have to start the trigger prior to the account creation, so we use the “before insert” trigger over the Account object. Likewise, according to the requirement, for the update event, therefore, we update the “before update” trigger over the Account object.

 Step 2:

 We use “set” for storing the “Ids” because we don’t require duplicate Ids of the account owner. So, we create an instance for that like the “SetAccowner”.

 Step 3:

After that, we use the “for” loop to all the new accounts; therefore, we use “trigger. new” in the loop. In the “for” loop, we add the account “OwnerId” in the set.

Step 4:

After that, we create the instance of the map “user map” that stores “value = user” and “Key = Id” along with the query. SELECT Name FROM user WHERE Id IN: setAccowner

Step 5:

After that, in the following “for” loop, we create the instance “usr” for the user, which is equivalent to the Account “owner” that we get from “map”.

Step 6:

In the end, the sales representative “sales_rep_c” is equivalent to “usr. Name”

Scenario 2:

Create the field with the name “Contact Relationship” checkbox over the contact object and generate an object known as “Contact Relationship” that is associated with contacts. Develop a logic while we create a connection by verifying the contact relationship checkbox; after that contact, the relationship is established systematically for the contact. Trigger:

Description

Step 1:

 According to the requirement, we perform the operation over the trigger when a user submits a record which means we have to use the “after insert” trigger. After that, when we have to check about an event, therefore we use “trigger. insert” and “trigger.isAfter” to dismiss trigger on these specific events.

Step 2:

 After that, we create an instance of the apex class “Contact Master Handler” as “ConIns”. After that, we call a “call Contact Relationship By Contact” method from the apex class.

Friday, 19 March 2021

Explain about ASP.NET Web API platform?

 You will use the ASP.NET Web API tool to build HTTP services that can be used by any device, including browsers and mobile phones. On the.NET Framework, it's an excellent forum for developing RESTful software.

These Web API guides will guide you through the fundamentals of ASP .NET online training Web API, from the beginning to the end. These are divided into parts, each of which includes a variety of relevant topics with easy-to-understand explanations, real-world illustrations, helpful hints, and a section of insightful notes.

What exactly is a Web API?

Let's look at what an API is before we look at what a Network API is (Application Programming Interface).

According to Wikipedia, an application programming interface (API) is a compilation of subroutine specifications, protocols, and resources for creating apps and applications in computer programming.

API stands for application programming interface, and it is a series of functions that allow programmers to access specific functionality or data of an application, operating system, or other resources.

Network API, as the name implies, is a web-based API that can be accessed using the HTTP protocol. It is a term, not a technical solution. We may build Web APIs with a variety of technologies, including Java, Dot net online training, and others. For example, Twitter's REST APIs allow us to read and write data programmatically, allowing us to incorporate Twitter's features into our application.

Web API for ASP.NET

The ASP.NET Web API is a tool for creating HTTP-based services that can be used in a variety of applications on a variety of platforms, including the web, Windows, and smartphone. It operates similarly to an ASP.NET MVC web application, except instead of sending an HTML display, it sends data as a response. It's similar to a web service or WCF service, but it only follows the HTTP protocol.

Characteristics of the ASP.NET Web API

  • The ASP.NET Web API framework is perfect for creating RESTful services.
  • The ASP.NET Web API is based on ASP.NET and uses the ASP.NET request/response pipeline.
  • HTTP verbs are mapped to function names in the ASP.NET Web API.
  • Different response data formats are provided by the ASP.NET Web API. JSON, XML, and BSON formats are all supported natively.
  • IIS, Self-hosted, or any other web server that supports.NET 4.0+ can host ASP.NET Web API.
  • To interface with the Web API server, the ASP.NET Web API module provides a new HttpClient. HttpClient can be found in ASP.MVC server-side applications, Windows Forms applications, Console applications, and other applications.

Create a Web API project.

You'll learn how to use Visual Studio to build a new ASP.NET Web API project.

There are two ways to start a Web API project.

  • MVC Project with Web API
  • Self-contained Project for a Web API

MVC and Web API -the undertaking

The Web API template in Visual Studio (2013/2015/2017) generates a new Web API project with an ASP.NET MVC framework and all the required references to get underway.

To do so, open Visual Studio and go to the File menu, then New Project. This will bring up the New Project popup, as seen below.

Create a Web API project.

Expand Visual C# in the New Project popup and tap the Web node in the left pane. In the middle pane, pick the ASP.NET Web Application prototype, then type a project name and press OK. (In Visual Studio 2017, use the ASP.NET Web Application (.NET Framework) template.)

The New ASP.NET Project popup will appear, on the screen you’re viewing.

In the popup above, choose Web API. The MVC and Web API check boxes have been selected and disabled as a result of this. It will generate the required directories and references for MVC and Web API.

To build a new Web API + MVC project, press Ok as shown below.

Plan for a Web API

This framework is identical to a standard MVC project, except for two Web API-specific files: WebApiConfig.cs in the App Start folder and Values Controller.cs in the Controllers folder, as seen below.

WebApiConfig.cs is a Web API configuration file. In the same way as Route Config.cs is used to configure MVC routes, you can configure routes and other stuff for web API. By default, it generates the Web API controller Values Controller.cs. In the next segment, you'll hear about WebApiConfig and Controller.

As a result, you can get started on your application by creating a Web API project with MVC.

Check out the Web API.

We built our first basic Web API project in the previous segment. Now we'll look at how to test Web API requests and responses locally during development.

For Web API testing, we can use the third-party resources mentioned below.

  • Fiddler
  • Postman

Fiddler 

Fiddler is a free web debugging proxy. It allows us to write and execute various HTTP requests to our Web API, as well as inspect the response.

Let's look at how to use Fiddler to make an HTTP request to our local Web API to see what we get back.

Step 1:

Fiddler can be downloaded and installed easily.

Step 2:

To start Fiddler, double-click Fiddler.exe after it has been installed successfully. It would resemble the illustration below.

Fiddler catches all operations by chance. We're just involved in messing in our internal systems. So, in the bottom left corner, press All Processes and then Hide All.

Hide All Processes in Fiddler

Step 3: 

Navigate to the Composer page. The Parsed tab is the first tab in the Composer tab, and it allows one to customize and execute HTTP requests. Both HTTP Methods are available in the first dropdown menu. Choose a specific HTTP form for the request you wish to file. We'll use GET to make an HTTP GET request, as seen below.

Now, in the corresponding textbox, type a request's URL. As seen below, we'll make an HTTP request to the Web API we built in the previous segment, http://localhost:xxxx/api/values.

To submit this HTTP message, click the Execute button, and the result will appear in the left pane as seen below.

Fiddler on the Roof's answer

To open the Inspector tab for the request, double-click on the result row above.

Fiddler on the Roof Request & Response

The top pane displays the Request header, while the bottom pane displays the answer, as seen above.

Click on the Raw tab of the request and response to see the raw request header and response, as seen below.

Postman

Postman is a free debugging application for APIs. It can be installed on your Mac or Chrome browser. It's available for Chrome here.

Open it after it has been successfully installed and choose HTTP Method, then enter the URL of your Web API as seen below.

Postman is a platform for checking web APIs.

To send an HTTP request to the given URL, click the Send button. 

Postman's Reaction

The data and response status are shown in the HTTP response, as seen above. As a consequence, Postman can be used to validate the Web API.

In the previous segment, we built a Web API with an MVC project that developed a simple controller. You will read everything there to know about Web API Controller in this article.

Conclusion

The Web API interface is equivalent to the MVC controller in ASP.NET. It takes care of incoming HTTP requests and responds to the caller.

A Web API controller is a class that can be generated in the Controllers folder or some other folder in the root folder of your project. A controller class must have a name that ends in "Controller" and be derived from the System. Web.HTTP. Api Controller class. Activity methods apply to any of the controller's public methods. You can learn more about web API in ASP.Net through ASP .Net online training Hyderabad.

Trigger Scenarios in Salesforce

  In Salesforce, Triggers are known as Apex Triggers. The triggers are unique and are accessible, particularly for general and anticipated a...