Vous êtes sur la page 1sur 13

Date

Date myDate = date.newinstance(2015, 6, 29);


Datetime dt = Datetime.newInstance(2008, 12, 1, 12, 30, 2);
<p> Today's Date is {! TODAY() } </p>
<p> Next week it will be {! TODAY() + 7 } </p>
<p>The year today is {! YEAR(TODAY()) }</p>
<p>Tomorrow will be day number {! DAY(TODAY() + 1) }</p>
<p>Is it true? {! CONTAINS('salesforce.com', 'force.com') }</p>

IF( MONTH( Birthdate) == 1,"January",


IF( MONTH( Birthdate) == 2,"February",
IF( MONTH( Birthdate) == 3,"March",
IF( MONTH( Birthdate) == 4,"April",
IF( MONTH( Birthdate) == 5,"May",
IF( MONTH( Birthdate) == 6,"June",
IF( MONTH( Birthdate) == 7,"July",
IF( MONTH( Birthdate) == 8,"August",
IF( MONTH( Birthdate) == 9,"September",
IF( MONTH( Birthdate) == 10,"October",
IF( MONTH( Birthdate) == 11,"November",
IF( MONTH( Birthdate) == 12,"December","None") ) ) ) ) ) ) ) ) ) ) )

datetime dt = datetime.newinstance(synthese.mois__c,
time.newinstance(0,0,0,0));
string mois = dt.format('MMMM');
Integer year = dt.year();

startDateTime = DateTime.newInstance(startDate, Time.newInstance(0, 0,


0, 0));
endDateTime = DateTime.newInstance(endDate, Time.newInstance(23, 59,
0, 0));

string startDTLiteral = DateTime.newInstance(startDate,


Time.newInstance(0, 0, 0, 0)).format('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
string endDTLiteral = DateTime.newInstance(endDate,
Time.newInstance(23, 59, 0, 0)).format('yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'');
string startDateLiteral = DateTime.newInstance(startDate,
Time.newInstance(0, 0, 0, 0)).format('yyyy-MM-dd');
string endDateLiteral = DateTime.newInstance(endDate,
Time.newInstance(23, 59, 0, 0)).format('yyyy-MM-dd');

HTML
<form>
Birthday (month and year):
<input type="month" name="bdaymonth">
</form>

Zip Resource Example


<apex:image url="{!URLFOR($Resource.TestZip,
'images/Bluehills.jpg')}"width="50" height="50" />

<id="theImage" src="[generatedId]/images/Bluehills.jpg" width="50"


height="50"/>

Apex
<p>{! IF( CONTAINS('salesforce.com','force.com'),
'Yep', 'Nope') }</p>

Sample for for creating contact


<apex:page standardcontroller="Contact">

<!-- First Name: <apex:inputfield value="{!Contact.FirstName}" /> <br />


Last Name: <apex:inputfield value="{! Contact.LastName}" /> <br />
Email: <apex:inputfield value="{!Contact.Email}" /> <br />-->
<apex:sectionHeader title="New Contact" subtitle="{!contact.Name}" />
<apex:form>
<div class="bPageBlock brandSecondaryBrd bEditBlock secondaryPalette">
<div class="pbHeader">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="pbTitle">
<img src="/s.gif" alt="" width="1" height="1" class="minWidth"
title=""/>
<h2 class="mainTitle">Contact Edit</h2>

</td>
<td class="pbButton" id="topButtonRow">
<apex:commandbutton action="{!save}" value="Save" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="pbBody">
<div class="pbSubheader brandTertiaryBgr tertiaryPalette">
<span class="pbSubExtra">
<span class="requiredLegend brandTertiaryFgr">
<span class="requiredExampleOuter">
<span class="requiredExample">&nbsp;</span>
</span>
<span class="requiredMark">*</span>
<span class="requiredText"> = Required Information</span>
</span>
</span><h3>Contact Information<span
class="titleSeparatingColon">:</span></h3>
</div>
<div class="pbSubsection">
<table class="detailList" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="labelCol">
<apex:outputtext value="{!$ObjectType.Contact.fields.Firstname.Label}" /></td>
<td class="dataCol"><apex:inputfield value=" {!contact.firstname}"
/></td>
</tr>
<tr>
<td class="labelCol"><apex:outputtext value="{!
$ObjectType.Contact.fields.Lastname.Label}" /></td>
<td class="dataCol"><apex:inputfield value=" {!contact.Lastname}"
/></td>
</tr>
<tr>
<td class="labelCol"><apex:outputtext value="{!
$ObjectType.Contact.fields.Email.Label}" /></td>
<td class="dataCol"><apex:inputfield value=" {!contact.Email}"
/></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="pbBottomButtons">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="pbTitle"><img src="/s.gif" alt="" width="1" height="1"
class="minWidth" title="" />&nbsp;</td>
<td class="pbButtonb" id="bottomButtonRow"></td>
<td class="pbButton" id="topButtonRow">
<apex:commandbutton action="{!save}" value="Save" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="pbFooter secondaryPalette"><div class="bg"></div></div>

</div>
</apex:form>
<apex:detail />
</apex:page>

HTML Links
<!-- <li> <a href="/{! a.id}">{! a.Name} </a> </li>-->

<a href="http://www.w3schools.com">This is a link</a>


<a href="default.asp">
<img src="smiley.gif" alt="HTML
tutorial"style="width:42px;height:42px;border:0">
</a>

a288E00000002v1QAA

The lang Attribute


<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html

paragraph
<!DOCTYPE html>
<html>
<body>

<p title="About W3Schools">W3Schools is a web developer's site.</p>

</body>
</html>

HTML Horizontal Rules


The <hr> tag creates a horizontal line in an HTML page.
The hr element can be used to separate content:

The HTML <pre> Element


The HTML <pre> element defines preformatted text.
The text inside a <pre> element is displayed in a fixed-width font (usually
Courier), and it preserves both spaces and line breaks:

HTML Styling
<body style="background-color:lightgrey">
<h1 style="font-size:300%;color:#ff0067">This is a heading</h1>
<h2>HTML <mark>Marked</mark> Formatting</h2>

Id and class
Use id to address single elements. Use class to address groups of
elements.

HTML Links - The target Attribute


The target attribute specifies where to open the linked document.
This example will open the linked document in a new browser window or in a
new tab:
<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>

The HTML <head> Element


The <head> element is a container for metadata (data about data).
HTML metadata is data about the HTML document. Metadata is not displayed.
Metadata typically define document title, styles, links, scripts, and other
meta information.
The following tags describe metadata: <title>, <style>, <meta>, <link>,
<script>, and <base>.

When to Use GET?


You can use GET (the default method):
If the form submission is passive (like a search engine query), and without
sensitive information.
When you use GET, the form data will be visible in the page address:

action_page.php?firstname=Mickey&lastname=Mouse
GET is best suited to short amounts of data. Size limitations are set in your
browser.

When to Use POST?


You should use POST:
If the form is updating data, or includes sensitive information (password).
POST offers better security because the submitted data is not visible in the
page address.

Apex variable
<apex:variable var="i" value="1" />
<table border="1" cellpadding="2" cellspacing="0">
<apex:repeat value="{! detailsynthese}" var="ds">
<td>

<apex:outputfield value="{!ds.ComAffecte__c}" />


<apex:outputtext value="{!i}" />
<apex:outputlabel >: </apex:outputlabel>
<apex:outputfield value="{!ds.NombrePistesAffectees__c}" />
</td>
<apex:variable var="i" value="{!VALUE(i)+1}" />
</apex:repeat>
</table>

Grouping Form Data with <fieldset>


The <fieldset> element groups related data in a form.
The <legend> element defines a caption for the <fieldset> element.

Loading JavaScript in HTML


Use simple syntax for loading external scripts (the type attribute is not
necessary):

<script src="myscript.js">
<head>
<script src="jquery-1.11.3.min.js">
</script>
</head>

jQuery CDN
If you don't want to download and host jQuery yourself, you can include it
from a CDN (Content Delivery Network).
Both Google and Microsoft host jQuery.
To use jQuery from Google or Microsoft, use one of the following:

Google CDN:
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>

jQuery Syntax
Basic syntax is: $(selector).action()

The Document Ready Event


You might have noticed that all jQuery methods in our examples, are inside a
document ready event:t k
$(document).ready(function(){
// jQuery methods go here...
});

This is to prevent any jQuery code from running before the document is
finished loading (is ready).

focus()
The focus() method attaches an event handler function to an HTML form
field.
The function is executed when the form field gets focus:
Example

$("input").focus(function(){
$(this).css("background-color", "#cccccc");
});

Static and void


public class Kevan {
public static gotosleep(){
}
public void gotoSleep(){
}
}
Kevan.gotoSleep();
Kevan k = new Kevan();
k.gotoSleep()

How to execute batch apex from developer


console?
Knowledge
Article
Number

000171199

Description How to execute a batch class from developer console?


Resolution From Developer Console:

1. Click Debug -> Open Execute Anonymous Window


2. Execute the following code
Id <variable name>= Database.executeBatch(new <Class name>(), batch size);
For eg:
Id batchJobId = Database.executeBatch(new RunThisBatch(), 200);
*batchjobId will contain the job Id of the batch.

date startDate = date.newinstance(2015,1,1);


date endDate = date.newinstance(2015,4,1);

Id batchjobid = Database.executeBatch(new
AP65_BatchGenerateSyntheseMensuelle( startDate, endDate, null), 200);

Header footer in vf
<apex:page renderAs="pdf" Controller="testpdf1">
<head>
<style type="text/css" media="print">
@page
{
size: 8.5in 11in;/* width height */
}
@page
{
@top-center
{
content: element(header);
}

@bottom-left
{
content: element(footer);
}

div.header
{
padding: 10px;
position: running(header);
}
div.footer
{
display: block;
padding: 5px;
position: running(footer);
}
.pagenumber:before
{
content: counter(page);
}
.pagecount:before
{
content: counter(pages);
}
</style>
</head>
<div class="header">
<div align="right">Header</div>

</div>
<div class="footer">
<div>Page <span class="pagenumber"/> of <span class="pagecount"/></div>
</div>
<div class="content">
<p>
<apex:repeat value="{!opp}" var="item">
<tr>
<td class="tableContent">{!item.Name}</td>
</tr>
</apex:repeat>
</p>
</div>
</apex:page>

My code
@page {
margin-top: 95px;
margin-bottom: 75px;
@top-left {
content: element(header);
}
@bottom-right {
content: element(footer);
}
}
.divStyleHeader{
padding: 5px;
position: running(header);
}
.footer {
display: block;
position: running(footer);
}

Sets
A set is an unordered collection of elements that do not contain any
duplicates. Set elements can be of any data typeprimitive types,
collections, sObjects, user-defined types, and built-in Apex types. For
example, the following table represents a set of strings, that uses city names:

'San Francisco'

'New York'

'Paris'

'To

Sets can contain collections that can be nested within one another. For
example, you can have a set of lists of sets of Integers. A set can contain up
to four levels of nested collections inside it, that is, up to five levels overall.
To declare a set, use the Set keyword followed by the primitive data type
name within <> characters. For example:
1

new Set<String>()

The following are ways to declare and populate a set:


1

Set<String> s1 = new Set<String>{'a', 'b + c'}; // Defines a new set with


two elements

Set<String> s2 = new Set<String>(s1); // Defines a new set that contains


the

// elements of the set created in


the previous step

Set<Integer> s = new Set<Integer>(); // Define a new set


s.add(1);
// Add an element to the set
System.assert(s.contains(1));
// Assert that the set contains an element
s.remove(1);
// Remove the element from the set

JavaScript
{!REQUIRESCRIPT("/soap/ajax/34.0/connection.js")}
var commande = "{!Suivi_de_Commande__c.Commande_OS__c}";
var chantierId= "{!Suivi_de_Commande__c.ChantierLookupId__c}";

if (commande == '00-OS Renta')


{
if(chantierId != null)
{
console.log("SELECT Id, PT_Chantier_Franchise_associe__c FROM Chantier__c
WHERE Id = '{!Suivi_de_Commande__c.ChantierLookupId__c}'");
result = sforce.connection.query("SELECT Id,
PT_Chantier_Franchise_associe__c FROM Chantier__c WHERE Id = '{!
Suivi_de_Commande__c.ChantierLookupId__c}'");
records = result.getArray("records");
if (records != null && records.length > 0)
{
var record = records[0];
if (record.PT_Chantier_Franchise_associe__c != null)

{
console.log("yes");
window.open("/apex/VFPAP67_OrdreDeService?id={!
Suivi_de_Commande__c.Id}", '_blank');
}
else
{
alert("{$AP67ErrorMessagePT}");
}
}
}
}
else
alert("{!$label.AP67ErrorMessageOS}");

currency conversion
/*
rA = SumMontantBudgete1;
ras = String.valueOf(rA);
System.debug('# ras is: ' + ras);
List<String> args = new String[]{'0','number','### ###
### ###'};
s1 = String.format(rA.format(), args);
if (ras.endswith('0')){
if(ras.substringAfter('.') == '00'){
af = ras.substringAfter('.');
rsult = s1 + (af != '' ? ',' + af : '');
System.debug('# final result is 00: ' + rsult);
}
else
if (ras.substringAfter('.') == '0'){
System.debug('# string of the decimal is : '
+ String.valueOf(rA));
af = ras.substringAfter('.');
rsult = s1 + (af != '' ? ',' + af : '')+'0';
System.debug('# final result is 0: ' + rsult);
}
else {
rsult = s1 + '0';
System.debug('# final result is xo: ' + rsult);
}
}
else
if ( ((ras.substringAfter('.')).length() == 1) &&
(ras.substringAfter('.') != '0') ) {

rsult = s1 + '0';
System.debug('# final result is x: ' + rsult);
}
else
if (string.isBlank((ras.substringAfter('.')))){
rsult = s1 +',00';
System.debug('# final result is blank: ' +
rsult);
}
else
System.debug('## final result is 0x:'+ s1);
*/
public Chantier__c chantierDummy {get;set;}
chantierDummy = new
Chantier__c(CoutInitialHT__c=SumMontantBudgete);

Vous aimerez peut-être aussi