APEX関連

Salesforce CollaborationGroup sObject in Apex Unit Tests

The below Test Class Code will occur [System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE] error if a same CollaborationGroup was existed,even Test Class dose not have the @IsTest(SeeAllData=true) annotation. As the document of Salesforce CollaborationGroup API [SOAP API Developer’s Guide],the Name of CollaborationGroup must be unique across public and private groups. […]

read more

Salesforce RemoteAction and webService

In Salesforce,we can make asynchronous requests from Visualforce Page,via RemoteAction or webService. I will share you the usage of RemoteAction and webService In this post.RemoteAction Using RemoteAction(JavaScript Remoting) allows us to call methods in Apex controllers and get a callback with return data from JavaScript. The @RemoteAction methods in Apex must be static and either […]

read more

The usage of apex:param in Visualforce Page

<apex:param> tag is used to pass values from JavaScript to an Apex controller,it can only be used with the folloing parent tags.   • <apex:actionFunction>   • <apex:actionSupport>   • <apex:commandLink>   • <apex:outputLink>   • <apex:outputText>   • <flow:interview> Here are some small examples of how you can pass a value via apex:param tag in Salesforce. Use <apex:param> in <apex:actionFunction> […]

read more

A bug caused by Decimal without SetScale

Let’s see the following Apex Script first. In fact the Apex Script will throw an AssertException.“System.AssertException: Assertion Failed: Expected: 0E-32%, Actual: 0%”. So we’d better round the Decimal before we convert it to String.Like the following Apex Script.

read more

Display DateTime with TimeZone in Visualforce Page

In Salesforce,Date and Date/Time values are stored in GMT,and a GMT time will be outputed when we use apex:outputText tag. e.g. Result ※Time Zone : (GMT+09:00) Japan Standard Time (Asia/Tokyo) As we know,we can not determine a user’s time zone in a formula,but there has two ways to fix this with Apex,maybe more. 1.Get User […]

read more

Date format and DateTime format

Date format in Apex 1.Use Date format method 2.Convert to String directly 3.Convert to DateTime DateTime format in Apex Date format in VF DateTime format in VF Date format in Formula DateTime format in Formula TZoffset is the difference between the user’s time zone and GMT。 When in Tokyo:TZoffset = “9/24” Reference : https://help.salesforce.com/help/pdfs/en/formula_date_time_tipsheet.pdf

read more

A way to make Thread Sleep in Apex

Sometimes we need make apex thread to sleep for a while, sush as testing if the soql with [For Update] works,and as we know the sfdc do not offer a method to sleep the thread. Then I thought it may work if I use the “while”, like the following code. Well, it looks not bad. […]

read more

How to access static resources from Apex, Visualforce and Custom Button

In Apex Normal file (with soql) Normal file (with PageReference.getContent) Zip file (with PageReference.getContent) ※Zip file can not be accessed by soql. In VF Normal file Zip file In Custom Button

read more

SFDC SObject Quick Panel – Quick access to Salesforce Standard Objects and Custom Objects

As a SFDC Developer,how do you open [Custom Object Setting] page, from [Setup] > [Create] > [Objects] > [Object Name] ? In fact,utilizing “sObject Quick Panel”,it could be more fast only need 1-Click. Screenshots Source code Download from Github That is all, Enjoy it!

read more

A simple Salesforce Trigger framework

Well,this is another Salesforce Trigger framework but more simple. Usage AccountTriggerHandler.cls AccountTrigger.trigger In normal case. Stop and resume sObject Trigger in APEX code Stop and resume a TriggerHandler in APEX code SourceCode Download from Github That is all, Enjoy it!

read more