In Salesforce, you can query accounts with at least one closed won opportunity by using a SOQL (Salesforce Object Query Language) query. Here’s an example of how you could write this query:
SELECT Id, Name, (SELECT Id, Name, StageName
FROM Opportunities
WHERE StageName='Closed Won')
FROM Account
WHERE Id IN (SELECT AccountId FROM Opportunity
WHERE StageName='Closed Won')
LIMIT 10
This query returns all accounts that have at least one opportunity in the “Closed Won” stage. The inner query (SELECT Id, Name, StageName FROM Opportunities WHERE StageName='Closed Won') retrieves the closed won opportunities associated with each account, and the outer query (SELECT Id, Name, (...) FROM Account WHERE Id IN (...)) retrieves the account information for accounts with at least one closed won opportunity.
You can use this query in a number of different ways, such as in the Salesforce Developer Console, in Apex code, or in a tool such as the Workbench. Once you have the results, you can use them for further analysis, reporting, or to perform additional actions.
Salesforce is one of the most popular enterprise software solutions on the market. It’s a customer relationship management (CRM) system that helps companies large and small to build relationships with customers, manage sales operations, and create customer experiences. Salesforce enables businesses to capture and maintain customers’ data and track the history of interactions between representatives and customers. With its numerous features, Salesforce provides an optimal user experience, delivering insights and ensuring collaboration between multiple stakeholders.
Salesforce offers an array of products and services related to customer relationship management, marketing automation, analytics and app development. With these tools companies can quickly create cloud-based applications and customer relationship management portals, such as order status, company portals and customer service. Salesforce products and services offer businesses the opportunity to connect with their customers and analyse campaigns for customer engagement.
Salesforce provides businesses with a suite of cloud-based applications to manage sales, customer service, marketing, and commerce. The platform is designed to help businesses better understand and manage their customer interactions and data throughout the customer lifecycle, with the goal of improving business relationships and driving sales growth. Salesforce provides tools to manage sales and customer data, automate marketing and sales processes, and create custom mobile and web applications. Additionally, Salesforce offers a platform for developing custom integrations and extensions, allowing businesses to customize the platform to meet their unique needs.
Companies acquired by Salesforce
Probably some of the products acquired by Salesforce you already use daily and you didn’t know that are part of the Salesforce ecosystem
Slack
Mulesoft
Heroku
Quip
Tableau
Vlocity
Should I use salesforce in my company?
Whether or not you should use Salesforce in your company depends on a number of factors, including the size and nature of your business, your specific business needs, and your budget. Here are a few factors to consider:
Size of your business: Salesforce is designed for large enterprises and can be a good fit for companies with hundreds or thousands of employees. However, it can also be used by small businesses with a more limited number of employees.
Type of business: Salesforce is widely used by businesses in a variety of industries, including technology, finance, healthcare, and retail. If your business is focused on sales and customer relationship management, then Salesforce might be a good fit.
Business needs: Salesforce offers a wide range of tools and features to help businesses manage their customer interactions and data, including sales automation, customer service, marketing automation, and commerce. If your business has a need for these types of tools, then Salesforce might be a good fit.
Budget: Salesforce can be an expensive solution, and costs can quickly add up depending on the number of users, the specific features and tools you need, and any customization or integration requirements. It’s important to consider the overall cost and return on investment before making a decision.
Ultimately, the best way to determine if Salesforce is a good fit for your company is to assess your business needs, explore the platform and its features, and consider the costs and benefits. It might also be helpful to consult with a Salesforce expert or partner to get a better understanding of how the platform can help your business.
Configuring the Salesforce CLI (Command Line Interface) on Mac can seem like a tedious task. However, it doesn’t have to be! There are simple steps you can follow to ensure that your Salesforce CLI is configured correctly for Mac. This post will outline the steps needed to successfully configure the Salesforce CLI on Mac.
The Salesforce CLI is a powerful tool that helps you develop, customize, and enhance your Salesforce applications. The CLI offers several commands that can be used to create, configure, update, deploy, and delete metadata components. The Salesforce CLI can be used on both Windows and Mac operating systems.
This guide will walk you through the steps you need to take to configure the Salesforce CLI for Mac.
You can ask for help on an specific command. For example, let’s ask how auth command works:
$ sfdx auth --help
Authenticate the Salesforce CLI.
$ sfdx auth
Select:
$ auth web login
Follow the OAuth steps. This will open a browser window from which you can log in. Once you’re done, you can use the. rest of the commands available in the SFDX CLI tool.
Once the authentication is done, you can close the tab and go to the command line to see:
$ Successfully authorized my@username.dev with org ID 00A9V000001wCajUAB
To start downloading metadata c reate Salesforce DX project in your local machine:
Configure Visual Studio Code to use Salesforce CLI
There are several Visual Studio Code plugins available to make it easier to use Salesforce CLI in your development process. You can install these plugins and configure them to use your Salesforce org.
Downloading a file from Salesforce using Java is not as difficult as it may seem. With the right tools and knowledge, you can quickly and easily download any type of file from Salesforce via a Rest API. To get started, you’ll need a few software tools and a few lines of code.
Let say we want to download a file stored in Salesforce. Have in mind we said a File and not an Attachment (the old way to deal with files in Salesforce), so we’ll have to deal with ContentDocument, ContentVersion, ContentDocumentLink, etc.
Agenda:
Salesforce security token
Partner API
Salesforce Rest API
Store a file
Implementation
We are going to use force-partner-api dependency to get a session id after login
If we use Maven, our pom.xml will have this dependency
Let’s have some constants to keep our params in one place.
private static final Logger LOG = Logger.getLogger(Main.class.getName());
private static final String USERNAME = "********";
private static final String ACCESS_TOKEN = "********";
private static final String PASSWORD = "********" + ACCESS_TOKEN;
private static final String INSTANCE_URL = "https://********-dev-ed.my.salesforce.com";
private static final String API_VERSION = "51.0";
private static final String SALESFORCE_FILE_ID = "0684W00000AzWoiQAF"; // ContentVersion id private static final String LOCAL_FILE_FULL_NAME = ""/tmp/sf-java.png"";
Important: the ACCESS_TOKEN constant represents the Salesforce security token you get from Settings -> Reset My Security Token
When you access Salesforce from an IP address that isn’t trusted for your company, and you use a desktop client or the API, you need a security token to log in. What’s a security token? It’s a case-sensitive alphanumeric code that’s tied to your password. Whenever your password is reset, your security token is also reset.
After you reset your token, you can’t use your old token in API applications and desktop clients.
The method to get the file (download and save it in our local disk)
Are you looking to add a bit of personality and flair to your lightning data table? Conditional cell color gives designers and developers the opportunity to transform their table into something unique and eye-catching.
With conditional cell color, you are able to control the color of a cell and its contents based on the value of a particular item in the table. This means that each cell in a row can have its own distinct color, letting you highlight important information, emphasize data, and make the table look more visually appealing.
Expected result
Salesforce Lightning is a component-based framework for building user interfaces on the Salesforce platform. It provides a modern and efficient way for developers to create and deploy custom user interfaces that can run on any device, including desktops, laptops, tablets, and smartphones.
A Lightning Component is a reusable unit of code that implements a specific feature or functionality. Components can be composed into larger applications and can be easily reused and customized to meet different business needs. They are written in Aura, a proprietary JavaScript-based language, and use the Lightning Data Service to communicate with the Salesforce server.
Lightning Components provide a number of benefits, including faster performance, improved user experience, and greater customization options compared to traditional Salesforce user interfaces. They are an essential part of the Salesforce Lightning platform and are widely used by organizations to build custom applications and extend the functionality of the Salesforce platform.
Lightning data tables allow users to customize the colors of cells in a table based on the values of the cell using conditional formatting. This is a powerful tool for quickly identifying trends and outliers in data sets. With Lightning data tables, Salesforce developers can set color thresholds to automatically color cells according to whether their value is above/below a certain value or between two values. This feature is especially useful for displaying numerical values such as sales data, which often need to be highlighted at a glance so that users can quickly identify areas for improvement.
Let say you want to highlight a cell in a Lightning data table (lightning:datatable) when a specific value is invalid. In our example, we want to display those invalid emails in red.
Salesforce content management allows users to store information such as documents, images, audio, and video files in their Salesforce org. On occasion, users may require to quickly and easily download certain content items from the Salesforce org using their own custom code.
Node-fetch is a popular Node.js library used by developers to create applications with the help of middleware, through a programming interface. Node-fetch is especially suitable for downloading Salesforce ContentVersion files.
Let’s download a file (ContentVersion) from Salesforce using node-fetch
Queueable interface allows apex developers to run complex, lengthy, and asynchronous processes that normally couldn’t be run in synchronous invocations. Queueables are simple to implement and provide several advantages over the old @future annotation, making them a great way to make sure your apex code runs reliably and efficiently.
Async processing is an efficient way to run our algorithms. This mostly involves queues to control how many executions are being processed at a time. Different languages and platforms implement async processing in different ways but the idea is the same. One of the ways (yes, there are more than one) in Salesforce to execute some algorithms that require heavy processing, is the interface Queueable. Another example is the annotation @future but we will put our focus on implementing the interface Queueable in Apex classes.
One of the big challenges for most of the async processing approaches is the absence of order on the execution. This is kind of “Do it when possible”.
In this example we are just inserting a new account. You may think that’s not a heavy operation but what if your org is full of Flows (Process Builder) or triggers that are being executed every time an account is inserted? CPU limit errors will appear soon unless you stay away of the main thread execution.
By using queueable, you will stay away from limits, especially CPU limits.
public class MyQueueable implements Queueable{
private final String myAttribute;
public MyQueueable(String myAttribute){
this.myAttribute = myAttribute;
}
public void execute(QueueableContext context) {
System.debug('executing with: '+myAttribute);
// do some heavy work
Account a = new Account(Name=myAttribute);
insert a;
// enqueue another job if you wish
}
public static void enqueueJob(){
ID jobID = System.enqueueJob(new MyQueueable('my test param'));
System.debug('job id: '+jobID);
}
}
How to enqueue our job
ID jobID = System.enqueueJob(new MyQueueable('my test param'));
Or you can create a method to use it as a shortcut
MyQueueable.enqueueJob();
How to monitor Apex Jobs
You can monitor Apex Jobs from Setup -> Environments -> Jobs -> Apex Jobs. Also you can query your job in case you have to something we them from your code or you just like monitor this way.
SELECT Status,NumberOfErrors, ExtendedStatus
FROM AsyncApexJob
ORDER BY CreatedDate DESC
How to write unit tests for Apex Jobs
@isTest
public class MyQueueableTest {
@isTest
static void myTest() {
String param = 'tes param '+Math.random();
// startTest/stopTest block to force async processes to run in the test.
Test.startTest();
System.enqueueJob(new MyQueueable(param));
Test.stopTest();
// Validate that the job has run by verifying that the record was created.
Account acct = [SELECT Name FROM Account WHERE Name = :param LIMIT 1];
System.assertEquals(param, acct.Name);
}
}
In Salesforce, developers can invoke Apex methods from within the Flow Builder to execute code logic. Apex methods provide the capability of customizing Flows as needed, allowing users to create new features, validate data, and access records or web services. This post will walk you through how to invoke an Apex method from the Flow Builder.
What about Flow Builder
Flow Builder is the replacement for Process Builder in Salesforce. Both of them are useful to automate several kinds of processes but sometimes the out-of-the-box functionality is not enough and we have to go to a custom one such as some lines in an Apex class. Let’s see then how to invoke an Apex method through the Flow Builder.
Create Apex class with Invocable method
public class MyFlowClass {
@InvocableMethod(label='My flow method'
description='A cool description about this method'
category='Account')
public static void execute(List<id> accountIds){
System.debug('account ids: '+accountIds);
}
}
</id>
Create the Flow
Remember to activate the Flow!
Test the Flow
Our flow will be executed every time we create or modify any account so let’s do that.
First of all open the Developer Console and go to the Logs tab. Open an account, edit any field and save it. After that see the log generated and make sure the debug line is present.
Salesforce and Amazon’s Web Services (AWS) are two powerful software development and cloud computing tools. In this post, we’ll discuss how these two tools can be integrated for an optimized and efficient workflow.
The integration of Salesforce and AWS allows businesses to take advantage of the scalability, reliability, and security of both platforms. The integration enables businesses to quickly and efficiently move key data and applications between the cloud platforms and reduces the complexity of integration.
There are many ways to sync up our Salesforce data with third parties in realtime. One option is a mix of Salesforce and AWS services, specifically Change Data Capture from Salesforce and AppFlow from AWS. We are going to build a Cloudformation yml file with all that we need to deploy our integration on any AWS environment. However can be a good option to do it first by point and click through the AWS console and then translate it into a Cloudformation template.
If you are using Heroku and Postgres, Heroku Connect is a good option too
About Salesforce Change Data Capture
Receive near-real-time changes of Salesforce records, and synchronize corresponding records in an external data store.
Change Data Capture
publishes change events, which represent changes to Salesforce records. Changes include creation of a new record, updates to an existing record, deletion of a record, and undeletion of a record.
Important:
Change Data Capture does not support relationships at the time this post was written (08/2021). This means you will only be able to sync up beyond your object unless you implement some tricks using Process Builder and Apex. That’s out of the scope of this post and we are going to see it in a different one because requires some extra steps and knowledge.
To start listening on specific object go to Setup -> Integrations -> Change Data Capture. Move the object you want to the right.
Advantages of using AppFlow approach
Data being transferred securely
Credentials are managed by Oauth process
No coding required unless you want to run some specific logic for every sync up
100% serverless, pay as use
Disadvantages of using AppFlow approach
The connection must exist before deploying the infrastructure. This is a manual step
This approach can take some time to learn and configure, specially if you are already familiar with callouts from Salesforce
Requirements for Salesforce
Your Salesforce account must be enabled for API access. API access is enabled by default for the Enterprise, Unlimited, Developer, and Performance editions.
Your Salesforce account must allow you to install connected apps. If this functionality is disabled, contact your Salesforce administrator. After you create a Salesforce connection in Amazon AppFlow, verify that the connected app named Amazon AppFlow Embedded Login App is installed in your Salesforce account.
The refresh token policy for the Amazon AppFlow Embedded Login App must be set to Refresh token is valid until revoked. Otherwise, your flows will fail when your refresh token expires.
You must enable change data capture in Salesforce to use event-driven flow triggers.
If your Salesforce app enforces IP address restrictions, you must grant access to the addresses used by Amazon AppFlow.
To create private connections using AWS PrivateLink, you must enable both Manager Metadata and Manage External Connections user permissions in your Salesforce account. Private connections are currently available in the us-east-1 and us-west-2 AWS Regions.
Architecture for the solution
Let say we want to listen to changes on Account object. Every time a new Account is created or updated there will be an event to AppFlow through Salesforce Data Capture.
We could add some logic in the Lambda function to decide if we are interested in that change or not.
How to create the Salesforce Oauth Connection
As we said, an Oauth connection must exist before deploying our stack to AWS. This is something we have to create by hand. If we deal with different environments in AWS, we can create as many connection as we want pointing to our different Salesforce instances.
Open your AWS console and go to Amazon App Flow
Go to View Flows and click on Connections
Click on Create Connection. Select production in case you have a dev org. Provide a connection name
Once you click on Continue, a Salesforce popup will be open. Put your Salesforce credentials to login
After that your connection will be created and available to use
It’s important we have a way to troubleshoot in case things go wrong. Since this integration deals with different AWS services, we have to see what we have available in each one.
The first question I asked myself when starting to write unit tests that involve files is: how do I upload files from my tests? Fortunately, dealing with files in Salesforce in a unit test context, is pretty easy.
Creating unit tests in Salesforce is a great way to ensure accurate data and maintain the integrity of Salesforce’s software applications. In this post, we’ll take a look at how to quickly and easily create text files in Salesforce to use them in your unit tests.
We are going to work with the new Salesforce files model and not with the old approach called “Notes and Attachments”.
If you still have Note and Attachments and you want to convert to Salesforce Files I recommend you install Magic Mover for Notes And Attachments to Lightning Experience
Straight to the point
Instantiate a ContentVersion with a name, description and a small content. In this case I will create a TXT file to keep it simple.
After creating the file we want to relate to one or many existing records such as an Account, Opportunity or even a custom object record.
To do that we have to insert a ContentDocumentLink
ContentDocumentLink cdl = new ContentDocumentLink();
cdl.ContentDocumentId = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id =: cv.Id].ContentDocumentId;
cdl.LinkedEntityId ='ANY ID'; // <----- put your record id here, example: an account tid
cdl.ShareType = 'V';
insert cdl;
Now go to the associated record and see the file attachment. You will have to add the Files related list to the layout in case you don’t have it yet.