Wednesday 19 February 2014

Difference between Insert and Database.Insert in Salesforce



Database.Insert
ü  Database methods are static methods available in Database class.

ü  Roll back is supported.

ü  Includes the optional allorNone parameters that defaults true.

ü  In bulk operation if error occurs, the remaining records will be inserted i.e. partial DML operation.

ü  Database methods allows additional features such as truncation features.
Insert 
ü  Roll back is not supported.

ü  In bulk operation if error occurs, the execution will stop and throws an error.

Example

For example, if you are inserting is 1000 records, 500 records are correct and remaining 500 records is Invalid means,
ü  In insert Operation 1000 records are failed, because if one records is invalid or error means all other remaining records will not be inserted it will through error.

ü  In Database.insert 500 records are inserted, remaining 500 records is failed.(i.e. Partial DML Operation)

Friday 14 February 2014

Date and DateTime Format / Syntax in Salesforce

Lot of time we struggled when formatting date and time in Salesforce, the below table helps you the Syntax for formatting Date and Time.



Date Field Symbols
Symbol
Meaning
Example(s)
G
era designator
G, GG, or GGG
GGGG
GGGGG
AD
Anno Domini
A
y
year
yy
or yyyy
96
1996
Y
year of "Week of Year"
Y
1997
u
extended year
u
4601
U
cyclic year name, as in Chinese lunar calendar
U
Q
quarter
or QQ
QQQ
QQQQ
02
Q2
2nd quarter
q
Stand Alone quarter
q or qq
qqq
qqqq
02
Q2
2nd quarter
M
month in year
or MM
MMM
MMMM
MMMMM
09
Sept
September
S
L
Stand Alone month in year
or LL
LLL
LLLL
LLLLL
09
Sept
September
S
w
week of year
or ww
27
W
week of month
W
2
d
day in month
d
dd
2
02
D
day of year
D
189
F
day of week in month
F
2 (2nd Wed in July)
g
modified julian day
g
2451334
E
day of week
E, EE, or EEE
EEEE
EEEEE
EEEEEE
Tues
Tuesday
T
Tu
e
local day of week
example: if Monday is 1st day, Tuesday is 2nd )
or ee
eee
eeee
eeeee
eeeeee
2
Tues
Tuesday
T
Tu
c
Stand Alone local day of week
or cc
ccc
cccc
ccccc
cccccc
2
Tues
Tuesday
T
Tu
a
am/pm marker
a
pm
h
hour in am/pm (1~12)
h
hh
7
07
H
hour in day (0~23)
H
HH
0
00
k
hour in day (1~24)
k
kk
24
24
K
hour in am/pm (0~11)
K
KK
0
00
m
minute in hour
m
mm
4
04
s
second in minute
s
ss
5
05
S
millisecond (maximum of 3 significant digits);
for S or SS, truncates to the number of letters

for SSSS or longer, fills additional places with 0
S
SS
SSS
SSSS
2
23
235
2350
A
milliseconds in day
A
61201235
z
Time Zone: specific non-location
z, zz, or zzz
zzzz
PDT
Pacific Daylight Time
Z
Time Zone: ISO8601 basic hms? / RFC 822
Time Zone: long localized GMT (=OOOO)
TIme Zone: ISO8601 extended hms? (=XXXXX)
Z, ZZ, or ZZZ
ZZZZ
ZZZZZ
-0800
GMT-08:00
-08:00, -07:52:58, Z
O
Time Zone: short localized GMT
Time Zone: long localized GMT (=ZZZZ)
O
OOOO
GMT-8
GMT-08:00
v
Time Zone: generic non-location
(falls back first to VVVV)
v
vvvv
PT
Pacific Time or Los Angeles Time
V
Time Zone: short time zone ID
Time Zone: long time zone ID
Time Zone: time zone exemplar city
Time Zone: generic location (falls back to OOOO)
V
VV
VVV
VVVV
uslax
America/Los_Angeles
Los Angeles
Los Angeles Time
X
Time Zone: ISO8601 basic hm?, with Z for 0
Time Zone: ISO8601 basic hm, with Z
Time Zone: ISO8601 extended hm, with Z
Time Zone: ISO8601 basic hms?, with Z
Time Zone: ISO8601 extended hms?, with Z
X
XX
XXX
XXXX
XXXXX
-08, +0530, Z
-0800, Z
-08:00, Z
-0800, -075258, Z
-08:00, -07:52:58, Z
z
Time Zone: ISO8601 basic hm?, without Z for 0
Time Zone: ISO8601 basic hm, without Z
Time Zone: ISO8601 extended hm, without Z
Time Zone: ISO8601 basic hms?, without Z
Time Zone: ISO8601 extended hms?, without Z
x
xx
xxx
xxxx
xxxxx
-08, +0530
-0800
-08:00
-0800, -075258
-08:00, -07:52:58
'
escape for text
'
(nothing)
' '
two single quotes produce one
' '
'





Examples:





Format Pattern
Result
yyyy.MM.dd G 'at' HH:mm:ss zzz
1996.07.10 AD at 15:08:56 PDT
EEE, MMM d, ''yy
Wed, July 10, '96
h:mm a
12:08 PM
hh 'o''clock' a, zzzz
12 o'clock PM, Pacific Daylight Time
K:mm a, z
0:00 PM, PST
yyyyy.MMMM.dd GGG hh:mm aaa
01996.July.10 AD 12:08 PM

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...