August, 2016
objects can’t be passed as arguments to future methods
The reason why objects can’t be passed as arguments to future methods is because the object can change between the time you call the method and the time that it actually executes. Remember, future methods are executed when system resources become available. In this case, the future method may have an old object value when […]
Apex REST annotations
@RestResource(urlMapping=’/yourUrl’) @HttpDelete @HttpGet @HttpPatch @HttpPost @HttpPut Favorite
Asynchronous Apex
In a nutshell, asynchronous Apex is used to run processes in a separate thread, at a later time. An asynchronous process is a process or function that executes a task “in the background” without the user having to wait for the task to finish. Here’s a real-world example. Let’s say you have a list of […]
Apex Variables
Null Variables and Initial Values If you declare a variable and don’t initialize it with a value, it will be null. In essence, null means the absence of a value. You can also assign null to any variable declared with a primitive type. For example, both of these statements result in a variable set to […]
Check Image File Size on Upload in Visualforce
Link <apex:page standardController=”Account” extensions=”AddAttachmentExt”> <apex:includeScript value=”https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js”/> <apex:form> <apex:sectionHeader title=”{!Account.name} Attachments” /> <apex:pageBlock mode=”maindetail”> <apex:pageBlockSection title=”Existing Attachments” columns=”1″> <apex:PageBlockTable value=”{!Account.Attachments}” var=”attach”> <apex:column value=”{!attach.Name}” /> <apex:column headerValue=”Length (bytes)” value=”{!attach.BodyLength}” /> <apex:column headerValue=”Owner” value=”{!attach.Owner.Name}” /> </apex:PageBlockTable> </apex:pageBlockSection> <apex:pageBlockSection title=”Add Attachment”> <apex:inputFile filename=”{!att.Name}” value=”{!att.Body}” /> <apex:commandButton value=”Upload” action=”{!addAttachment}” onclick=”return checkFileSize();”/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <script> function getIEFileSize(file){ var myFSO = […]
Apex Input File type validation using Java Script
<apex:page controller=”AttachmentUploadController”> <apex:sectionHeader title=”Visualforce Example” subtitle=”Attachment Upload Example”/> <apex:form enctype=”multipart/form-data”> <apex:pageMessages /> <apex:pageBlock title=”Upload a Attachment”> <apex:pageBlockButtons > <apex:commandButton action=”{!upload}” value=”Save”/> </apex:pageBlockButtons> <apex:pageBlockSection showHeader=”false” columns=”2″ id=”block1″> <apex:pageBlockSectionItem > <apex:outputLabel value=”File Name” for=”fileName”/> <apex:inputText value=”{!attachment.name}” id=”fileName”/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value=”File” for=”file”/> <apex:inputFile onchange=”check(this)” value=”{!attachment.body}” filename=”{!attachment.name}” id=”file”/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value=”Description” for=”description”/> <apex:inputTextarea value=”{!attachment.description}” id=”description”/> […]
Uploading attachment
<apex:page controller=”AttachmentUploadController”> <apex:sectionHeader title=”Visualforce Example” subtitle=”Attachment Upload Example”/> <apex:form enctype=”multipart/form-data”> <apex:pageMessages /> <apex:pageBlock title=”Upload a Attachment”> <apex:pageBlockButtons > <apex:commandButton action=”{!upload}” value=”Save”/> </apex:pageBlockButtons> <apex:pageBlockSection showHeader=”false” columns=”2″ id=”block1″> <apex:pageBlockSectionItem > <apex:outputLabel value=”File Name” for=”fileName”/> <apex:inputText value=”{!attachment.name}” id=”fileName”/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value=”File” for=”file”/> <apex:inputFile value=”{!attachment.body}” filename=”{!attachment.name}” id=”file”/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value=”Description” for=”description”/> <apex:inputTextarea value=”{!attachment.description}” id=”description”/> </apex:pageBlockSectionItem> […]
Date format(‘mm/dd/yyyy’) in Apex
Datetime dtStartDate = (Datetime) offerRecord.Campaign_Start_Date__c; wrapper.OfferCampaignStartDate = dtStartDate.format(‘MM/dd/yyyy’); Favorite
Force.com site vs. Site.com
Resolution Force.com Sites: Force.com sites supports both authenticated and public websites (i.e. the legacy portal products). Included in all Enterprise Edition (or above) and Developer orgs. Support for custom pages using Visualforce, JavaScript, CSS. Main target audience is for users that are developers familiar with the above languages. Can access all Force.com objects. A full […]
DML Limits
-DML governing limits: You can have only 150 DML statements with in a transaction; If you have more than 150 DML statements you will get an error “Too many DML statement : 151 To rectify this type of erros by using bulkify operations which is put similar operation on object in the list and invoke […]