Skip to main content

Posts

Showing posts with the label File

Latest Post

Custom Metadata Types vs Custom Settings vs Custom Labels

  Custom Metadata Types vs Custom Settings vs Custom Labels 💬 In plain words:  Three lookalikes: Custom Metadata = configuration that DEPLOYS with your code (best for app settings). Custom Settings = org/user-specific values, changeable at runtime (hierarchy type is great for bypass switches). Custom Labels = translatable text for the UI. 📌 Example:  API endpoint URLs per environment → Custom Metadata (deploys with code, sandbox vs prod values). A 'Bypass_Automation__c' checkbox an admin flips during data load → hierarchy Custom Setting. The word 'Submit' translated to Hindi → Custom Label. 🎬 Real-Life Example: The Fee Table Trapped Inside Code  Skyline charges a different delivery fee per city. Apex needs those rates on every booking. The Old/Bad Way:  if (city == 'Delhi') fee = 50. Else if (city == 'Mumbai') fee = 65. … Every rate change is a code change, a test run, and a deployment. Why this is bad:  Business data is trappe...

Upload file using multipart/form data from apex salesforce

Here is a solution to upload a file to a third-party system using Apex in Salesforce. Below is the FormData builder Apex class, which builds the required multipart parameters: public class FormData { private final static String Boundary = '1ff13444ed8140c7a32fc4e6451aa76d'; public enum EndingType { Cr, CrLf, None } /** * Returns the request's content type for multipart/form-data requests. */ public static String GetContentType() { return 'multipart/form-data; charset="UTF-8"; boundary="' + Boundary + '"'; } /** * Pad the value with spaces until the base64 encoding is no longer padded. */ private static String SafelyPad(String value, String valueCrLf64, String lineBreaks) { String valueCrLf = ''; Blob valueCrLfBlob = null; while (valueCrLf64.endsWith('=')) { value += ' '; value...

Apex and Visualforce Page Code for Veeva Vault Integration

Introduction: Veeva Vault is a widely used content management system (CMS) in the life sciences industry. Integrating Veeva Vault with Salesforce allows organizations to seamlessly manage and access their regulated content within the Salesforce platform. In this blog post, we will explore how to integrate Veeva Vault with Salesforce using Apex and Visualforce. We will provide code examples and step-by-step instructions to help you get started with the integration. Step 1: Set Up the Veeva Vault Integration: 1. Obtain Veeva Vault API Credentials:    - Contact your Veeva Vault administrator or support team to obtain the API credentials required for integration.    - Obtain the following information: Veeva Vault API Endpoint URL, Client ID, Client Secret, and Redirect URI. 2. Create Remote Site Settings in Salesforce:    - Go to Setup.    - Search for "Remote Site Settings" and click on it.    - Click on "New Remote Site" and pro...

How to Create a File Upload Component in LWC Salesforce

 To create a file upload component in Lightning Web Components (LWC) for Salesforce, you can utilize the built-in lightning-file-upload  component and handle the file upload logic in the corresponding JavaScript file. Here's an example of how you can implement a file upload component in LWC: uploadFile: <template>     <lightning-card title="File Upload Component">         <lightning-file-upload             label="Upload File"             name="fileUploader"             accept=".pdf,.png,.jpeg"             record-id={recordId}             onuploadfinished={handleUploadFinished}>         </lightning-file-upload>     </lightning-card> </template> uploadFile.js: import { LightningElement, api } from 'lwc'; export default c...

Apex Code for Uploading Files Using Multipart/Form Data in Salesforce

Introduction: In Salesforce, there are various ways to upload files and attachments. One common requirement is to upload files using the multipart/form data format. This format allows you to send file data along with additional form parameters in a single request. In this blog post, we'll explore how to accomplish this using Apex code in Salesforce. Prerequisites: Before diving into the implementation, make sure you have the following prerequisites in place: Salesforce Developer Edition or Sandbox account. Basic knowledge of Apex programming language. Salesforce org with the necessary permissions to create Apex classes and Visualforce pages.

Popular Posts