tag:blogger.com,1999:blog-54146613017574530992024-02-06T19:53:17.757-08:00Shared PoolAnonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-5414661301757453099.post-27432647349783641372016-07-03T23:33:00.003-07:002016-07-03T23:45:35.300-07:00System.CalloutException: Server chose TLSv1, but that protocol version is not enabled or not supported by the client<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="https://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="https://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
I recently come across a situation where I faced an issue
while calling a web service. It took me several hours to get the exact reason.
Sharing it if it can help someone & save time.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In the requirement, there was a .net web service & I am
calling it from the salesforce code. The code is having normal HTTP call steps
as below-<o:p></o:p><br />
<br />
<br /></div>
<pre class="brush: csharp">HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setHeader('Content-Type','text/xml; charset=utf-8');
req.setEndpoint("YOUR_HTTPS_ENDPOINT");
req.setBody("SET_BODY");
req.setHeader('SOAPAction','http://www.XXX.com/schemas/FunctionABC');
res = http.send(req);
</pre>
here when I was sending this http request, getting below issue-
<br />
<br />
<pre>System.HttpRequest retrying request in response to handshake failure:
Server chose TLSv1, but that protocol version is not enabled or not supported
by the client.</pre>
<pre>
</pre>
<pre><o:p></o:p></pre>
<span style="font-family: Calibri, sans-serif;"><span style="font-size: 14.6667px; line-height: 15.6933px;">System.CalloutException: Server chose TLSv1, but that protocol version is not enabled or not supported by the client.</span></span><br />
<span style="font-family: "Calibri",sans-serif; font-size: 11.0pt; line-height: 107%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Mangal; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><br /></span>
<span style="font-family: "Calibri",sans-serif; font-size: 11.0pt; line-height: 107%; mso-ansi-language: EN-US; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: Mangal; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJDDqsjIiG7vawJJeMf1vp_uT_v4wv2dvPUQ4JUAWyLV2wXepdIy_KmEb1q73Ud6CxrXlDxo0aSBWCJhAmII4bT8w0FVOOEd93tJbmI0wzVF9zxf0BsaX0K-mOn9hzJUmZmv1PAbTEp3A/s1600/1.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" height="17" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJDDqsjIiG7vawJJeMf1vp_uT_v4wv2dvPUQ4JUAWyLV2wXepdIy_KmEb1q73Ud6CxrXlDxo0aSBWCJhAmII4bT8w0FVOOEd93tJbmI0wzVF9zxf0BsaX0K-mOn9hzJUmZmv1PAbTEp3A/s640/1.PNG" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Tried couple of ways to solve it but nothing worked. Finally,
I start looking into the salesforce documentation & I found below url –<o:p></o:p></div>
<div class="MsoNormal">
<a href="https://help.salesforce.com/apex/HTViewSolution?id=000221207" target="_blank">https://help.salesforce.com/apex/HTViewSolution?id=000221207</a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
as per the salesforce documentation, salesforce disabled TLS
1.0, because of that I was getting that exception. Client org was the latest
one & due to that it is already disabled in that org.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
I tried the same code in one of my old org & that works.
This code can work only if you can see below line in setup<span style="font-family: Wingdings; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;">à</span> critical update
section –<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl5SCu9WtejERyJn4_kdJMIOzxdP4KlIwgaws8J8-Qcs6blyGk1WcE1wvmvk2jqLuQh5LAnEhR-w5j5KEZVlUoD6g1PmzfxufPHuoTlEeOsDUOfjY_OQk5TZLNmrStGd13pZY446ihpL4/s1600/2.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="23" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl5SCu9WtejERyJn4_kdJMIOzxdP4KlIwgaws8J8-Qcs6blyGk1WcE1wvmvk2jqLuQh5LAnEhR-w5j5KEZVlUoD6g1PmzfxufPHuoTlEeOsDUOfjY_OQk5TZLNmrStGd13pZY446ihpL4/s400/2.PNG" width="400" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgl5SCu9WtejERyJn4_kdJMIOzxdP4KlIwgaws8J8-Qcs6blyGk1WcE1wvmvk2jqLuQh5LAnEhR-w5j5KEZVlUoD6g1PmzfxufPHuoTlEeOsDUOfjY_OQk5TZLNmrStGd13pZY446ihpL4/s1600/2.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Please notice that, the code works well here because I did
not activated above update yet on my old dev org.</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
I am not sure what needs to be done at service end to fix
the issue but this is just an idea if someone facing the issue. At least he can
get what the reason behind the issue. <o:p></o:p></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-92067524236889843742016-05-31T00:12:00.002-07:002016-09-10T19:05:30.801-07:00Setup MavensMate for salesforce - Windows 10<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
Recently I got a chance to setup MavensMate at windows 10 machine for salesforce. I tried but there were couple of issues which I faced. Just sharing the blog post to get rid of those issues & setup MavensMate on Windows 10 Machine.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<br />
<div class="MsoNormal">
#1-Install Sublime text 3 from below link –<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<a href="https://www.sublimetext.com/3" target="_blank">https://www.sublimetext.com/3</a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcx2wXL9-B-Sl1uRa-ATC_TzNzS1OhDpAXayBTq17plEVmmQDbXd5isBZrNVg0RKEPJ_hOmnT27qbZnZrwbAcVPWMHgFSkNCFbTvhXZGCVas2Et8XMwmB_paKpG2oM0nrKQVeH_jSQQ24/s1600/img1.png" imageanchor="1"><img border="0" height="169" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcx2wXL9-B-Sl1uRa-ATC_TzNzS1OhDpAXayBTq17plEVmmQDbXd5isBZrNVg0RKEPJ_hOmnT27qbZnZrwbAcVPWMHgFSkNCFbTvhXZGCVas2Et8XMwmB_paKpG2oM0nrKQVeH_jSQQ24/s320/img1.png" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#2-Click on the red marked link. <o:p></o:p></div>
<div class="MsoNormal">
#3-Download & install this, restart sublime text after
it is installed.<o:p></o:p></div>
<div class="MsoNormal">
<span style="font-family: "calibri" , sans-serif; font-size: 11.0pt; line-height: 107%;">#4-open url -<a href="https://packagecontrol.io/installation" target="_blank"> https://packagecontrol.io/installation</a> </span></div>
<div class="MsoNormal">
<span style="font-family: "calibri" , sans-serif; font-size: 11pt; line-height: 107%;">#5-Copy
red marked text</span></div>
<div class="MsoNormal">
<span style="font-family: "calibri" , sans-serif; font-size: 11.0pt; line-height: 107%;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0-S__j3uU2CFDpCCAzQMrdKhiltjBKG-fM0jtiH1G0f8TZNPMcoHVdQwELwY9JqfWwSXHH1VU0CbJoePjyb5HAEoJSIh8Nk2jWKTyZpIZb5zPlpyIIG9h_5alkuZpQSfzZcjvtBkXBAY/s1600/img2.png" imageanchor="1"><img border="0" height="243" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0-S__j3uU2CFDpCCAzQMrdKhiltjBKG-fM0jtiH1G0f8TZNPMcoHVdQwELwY9JqfWwSXHH1VU0CbJoePjyb5HAEoJSIh8Nk2jWKTyZpIZb5zPlpyIIG9h_5alkuZpQSfzZcjvtBkXBAY/s320/img2.png" width="320" /></a></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#6-Open console in sublime text. You can find this option at
View <span style="font-family: "wingdings"; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;">à</span>
Show Console.<o:p></o:p></div>
<div class="MsoNormal">
#7-Paste this long text in console & hit enter.<o:p></o:p></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
#8-If it is failed try one more time. Once this is done
restart sublime text.<o:p></o:p></div>
<div class="MsoNormal">
#9-Go to preferences <span style="font-family: "wingdings";">à</span>
package control</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
Type install MavensMate & hit enter<o:p></o:p></div>
<div class="MsoNormal">
#10-Restart Sublime text </div>
<div class="MsoNormal">
#11-Create a folder in your directory for workspace.</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
For Eg – D:\ Mavensmate_Workspace<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#12-open sublime text, go to MavensMate <span style="font-family: "wingdings";">à</span> Setting <span style="font-family: "wingdings";">à</span> User</div>
<div class="MsoNormal">
<o:p></o:p></div>
<div class="MsoNormal">
You will see a node – “mm_workspace", put your
workspace path here.<o:p></o:p></div>
<div class="MsoNormal">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFJPnr3ITNo0w_Elc_4CLECLEDwIc6hXzp2RG6SsHuxLG7HaK3Cyn6HwE-KrnH3mGbELhePkmOIIvzWM18MZMdfGLtu9jqHtpVmOFQ33L77Exb3lDAhB2XqlpJzTgB9QW2FE0auy9oCbU/s1600/img3.png" imageanchor="1"><img border="0" height="34" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFJPnr3ITNo0w_Elc_4CLECLEDwIc6hXzp2RG6SsHuxLG7HaK3Cyn6HwE-KrnH3mGbELhePkmOIIvzWM18MZMdfGLtu9jqHtpVmOFQ33L77Exb3lDAhB2XqlpJzTgB9QW2FE0auy9oCbU/s320/img3.png" width="320" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#13-To create a new project, go to MavensMate <span style="font-family: "wingdings"; mso-ascii-font-family: Calibri; mso-ascii-theme-font: minor-latin; mso-char-type: symbol; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-symbol-font-family: Wingdings;">à</span> New Project<o:p></o:p></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
#14-It will open url in Edge browser. This may show you
below error, when you enter the login detail & try to create project.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKAxit7stERJUkxot9d3Ta_-XEFnLexa7lV7tR6K4nQp9VRps06tvb43gsJPIcnuIZqSZyTzScadhM22WaaCDAMXbCYV2TUEifrVmXi8fvgABazD0gqSjK2KrWtB5Rbmzyf2cAJCgbzsk/s1600/img6.png" imageanchor="1"><img border="0" height="40" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKAxit7stERJUkxot9d3Ta_-XEFnLexa7lV7tR6K4nQp9VRps06tvb43gsJPIcnuIZqSZyTzScadhM22WaaCDAMXbCYV2TUEifrVmXi8fvgABazD0gqSjK2KrWtB5Rbmzyf2cAJCgbzsk/s640/img6.png" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#15-To resolve this issue, copy url (which is in Edge) & open firefox & paste it here, hit enter. Put all the login details & create project from here.<o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#16-You may see another error after this, error would be <b>[XXX]
- Access is denied</b>.<o:p></o:p></div>
<div class="MsoNormal">
To resolve this go to your workspace folder, right click, go to security & give all permissions to current user & all other user as well & then try
to create.<o:p></o:p></div>
<div class="MsoNormal">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQYi4HQjLBYXE4zFY_YLTxIXEH9JZTQcShSuCTWGX0cg9CrSrEqvgCzThiDIoOAybmIRDO9RtGuX9sVUHsniXTjWVMnq7ImGbpAm4mgEbJoklZdm8awUc_31vF1bzs8VBdlTX9jMADVs/s1600/img5.png" imageanchor="1"><img border="0" height="126" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixQYi4HQjLBYXE4zFY_YLTxIXEH9JZTQcShSuCTWGX0cg9CrSrEqvgCzThiDIoOAybmIRDO9RtGuX9sVUHsniXTjWVMnq7ImGbpAm4mgEbJoklZdm8awUc_31vF1bzs8VBdlTX9jMADVs/s320/img5.png" width="320" /></a></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
This will solve your issue & will create a new project!!<o:p></o:p><br />
<br />
<b><span style="color: red;">Update - 11 Sept 2016</span></b><br />
<b>--------------------------------------------</b><b>--------------------------------------------</b><br />
Result: [ERROR]: Request to the local MavensMate server failed. please ensure the MavensMate-app is installer and running.<br />
<br />
In version 7+ of MavensMate for Sublime Text, there is a new companion app called MavensMate-app. You must download, install, and run this application in order for the MavensMate for Sublime Text plugin to operate. For more information, please visit https://github.com/joeferraro/MavensMate-app<br />
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0UQ-jS6SFd3hNfLMU-xDXE7nyb-qkP4ftoDQ-Maszud1gm1w7xyJnutv0Ikm6ruUmmgBpJqBN_shjx6AjefTASFZTofFGOYRSfmiiT7Ri-ZbSLm1ytCD36LhmelA90yua-0OtsCEW_LM/s1600/Capture.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="31" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0UQ-jS6SFd3hNfLMU-xDXE7nyb-qkP4ftoDQ-Maszud1gm1w7xyJnutv0Ikm6ruUmmgBpJqBN_shjx6AjefTASFZTofFGOYRSfmiiT7Ri-ZbSLm1ytCD36LhmelA90yua-0OtsCEW_LM/s320/Capture.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
To resolve this issue, open url <a href="https://github.com/joeferraro/MavensMate-Desktop/releases" target="_blank">https://github.com/joeferraro/MavensMate-Desktop/releases</a></div>
<div class="separator" style="clear: both; text-align: left;">
Go to download section & download the exe according to OS.</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVZtx0opirAT4_HGzvpwZIvBKnANq_Mob03DqCcq2bHNcDp6wMGV2QX1dfhoAlRsm01s0vk9CEcgzqjMu3GTXtCYIcf63qR1cwk74lbWLEhD7tTa0EDPHXFIonv7ZVCuRAQjVJ0ebeY1I/s1600/Capture2.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="118" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVZtx0opirAT4_HGzvpwZIvBKnANq_Mob03DqCcq2bHNcDp6wMGV2QX1dfhoAlRsm01s0vk9CEcgzqjMu3GTXtCYIcf63qR1cwk74lbWLEhD7tTa0EDPHXFIonv7ZVCuRAQjVJ0ebeY1I/s320/Capture2.PNG" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
install this, & whenever you want to run sublime text + mavensmate, you need to run this app first. after installation go to search & click on Mavensmate app first & then open sublime text. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div>
<br /></div>
</div>
<div class="MsoNormal">
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com9tag:blogger.com,1999:blog-5414661301757453099.post-72588996366616883812015-07-09T21:02:00.000-07:002015-07-09T21:02:43.594-07:00As a beginner MAC OS user with Salesfoce<div dir="ltr" style="text-align: left;" trbidi="on">
I am a window user & shifted on MAC recently, this move was not easy & come up with several issues. Struggling phase with MAC is still going on because when you start using MAC you realize that you don't know even simplest thing too :) a bit frustrating!<br />
<br />
<br />
Couple of issued while setting up Eclipse + Force.com IDE for MAC OS, just sharing experience so you can save your time if you face this kind of issues.<br />
<br />
<b>1-</b>In my eclipse I did not see autocomplete after foce.com ide installation, tried various tricks from internet but nothing works, after a lot of wasting time I came to know that I should install version 30 to see autocomplete feature, probably this is not available in latest releases.<br />
<br />
Here is how you can do it-
I am assuming you are already have an idea of below link<br />
<a href="https://developer.salesforce.com/page/Force.com_IDE_Installation" target="_blank">Foce.com IDE</a><br />
<br />
When you add a "Foce.com IDE" & click on add there is a checkbox "Show Only latest Version Of Available Software", you need to uncheck it.<br />
You will see couple of versions for Force.com IDE. You should select version 30 & after that install it.You will see autocomplete after this installation.<br />
<br />
<br />
<b>2</b>-The other issue, which I was facing, is<br />
<b> "An internal error occurred during: "Computing size".
The profile is currently in use." </b><br />
<br />
After wasting a lot of time I came to know that, error is due to I am trying to install eclipse + Force.com Ide on FAT 32 partition. & Due to that it is not installing "Force.com IDE".<br />
I moved it on MAC drive (Mac OS Extended (Journaled)) & that starts working.<br />
<br />
<b>3</b>.I was trying to install the data loader on MAC but many people said dataloader is not build for MAC, it is build for windows only, after wasting some time, I got the version for MAC.<br />
<br />
You can go to your salesforce org
Setup >> Data Management >> Data Loader >> Download for MAC<br />
<br />
<b>4</b>.I also tried if data loader command line tool can work on MAC, but still struggling with this. Probably it is not for MAC, OR it will take some time if any trick can work. But for now it is not working.<br />
<br />
Also noticed that if you are using command line in windows & using latest version that will not work, you need to download version 30 for this & that will work.<br />
You can download older version from this link.<br />
<a href="http://www.cloudsuccess.com/resource-centre/apex-data-loader-archive/" target="_blank">http://www.cloudsuccess.com/resource-centre/apex-data-loader-archive/</a><br />
<br />
5. As a beginner in MAC I noticed that I see Question mark for some app's. This one is not related to salesforce ☺.<br />
When I click on them it will show a popup with that app & application folder. I don't understand it why it is doing like this even I have installed app.<br />
At other hand when I am trying to removing some dmg file from hard drive it is showing a message that it can not be deleted.<br />
<br />
Solution is very simple for this issue:-<br />
a-when it shows a popup, you need to move that app in application folder, this is what it is trying to tell user by showing that popup but as a beginner it is not easy to understand.<br />
<br />
b- When I did this, I could delete those dmg files too.
To check from where app is working go to dock right click on app & click show in finder, it will show the place from where app is running.<br />
<br />
c-All apps should run from application folder, so first move app in application folder & then drag & drop that app in dock. Right click on this icon & select "Keep this in doc" & that's it.</div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-55979054457989511022015-04-30T23:40:00.000-07:002015-04-30T23:40:02.064-07:00A Web Service CallOut Per Minute In Between Business Hours<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<div dir="ltr" style="text-align: left;" trbidi="on">
There was a very specific requirement from customer, as per the requirement he wanted to call a external websrvice in every minute during the business hours. I tried several ways to do it but that was really not simple. Even I was not sure it can hit any governor limit.
I did google a lot for this but there was no help in case of per minute. Finally started to get if there is any solution in salesforce for this, without having confidence is this really possible in salesforce. But finally I got the solution & the best thing is it works without hitting any kind of governor limits. Here is the solution which can help if you stuck this kind of requirement.<br/><br/>
#1-Create a new object called “Scheduled_Job__c”. This object will have below fields –<br/>
Request_DateTime__c – Type DateTime<br/>
Response__c – Type Long Text Area(32768)<br/><br/>
This object will be used in two ways latter-<br/>
#A-track the request time & <br/>
#B-What is the response from the external web service.<br/>
#2-I created a batch class which allows callouts.<br/>
<pre class="brush: c#">
global class ScheduleLeads implements Schedulable,Database.AllowsCallouts {
global void execute(SchedulableContext ctx) {
init();
}
}
</pre><br/>
#3-Created a method in this class called ScheduleJob which will basically can be called from execute anonymous to schedule this job.<br/>
<pre class="brush:c#">
public static void ScheduleJob(){
boolean isNeedToSchedule = true;
String strSchedule = '';
/*here notice that we are adding a minute in current time, means it will be scheduled for next minute, you can change it even if you want to call every n minutes*/
DateTime dt = Datetime.now().addMinutes(1);
/*Let’s say business hours is from 10 AM to 8 PM*/
if(dt.hour() >=19 && dt.minute() >= 59){
isNeedToSchedule = false;
}else{
strSchedule = '0 ' + dt.minute() + ' ' + dt.hour() + ' ' + dt.day() + ' ' + dt.month() + ' ?' + ' ' + dt.year();
isNeedToSchedule = true;
}
if(isNeedToSchedule){
String cronid = System.schedule('CalloutService_' + Datetime.now().getTime(), strSchedule, new ScheduleVWLeads());
List<Scheduled_Job__c> listOfScheduledJob = [Select Id,Response__c from Scheduled_Job__c Order by CreatedDate DESC LIMIT 1];
if(listOfScheduledJob != NULL && !listOfScheduledJob.isEmpty()){
/*try{
delete listOfScheduledJob;
}catch(Exception ex){
system.debug('exqqq::--->>>>' + ex);
}*/
}
Scheduled_Job__c objScheduledJob = new Scheduled_Job__c();
objScheduledJob.Name = cronid;
objScheduledJob.Request_DateTime__c = datetime.now();
insert objScheduledJob;
}
}
</pre><br/>
#4-Create another method called init <br/>
<pre class="brush:c#">
@future(callout=true)
public static void init(){
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('GET');
String requrl = 'YOUR_WEBSERVICE_URL'+ '?type=' + XYZ;
req.setEndPoint(requrl);
HTTPResponse res;
if(!Test.isRunningTest()){
Blob headerValue = Blob.valueOf('YOUR_WEBSERVICE_USERID' +':' +'YOUR_WEBSERVICE_PASSWORD');
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setTimeout(120000);
res = http.send(req);
}else{
res = new HttpResponse();
res.setHeader('Content-Type', 'application/json');
res.setBody('DUMMY_RESPONSE_IN_CASE_OF_TEST_EXECUTES');
res.setStatusCode(200);
res.setStatus('Ok');
}
String resBody;
if(res != NULL){
resBody = res.getBody();
JSONParser parser = JSON.createParser(resBody);
while (parser.nextToken() != null) {
/*PROCESS YOUR RESPONSE HEREE */
}
ScheduleJob();
}
}
</pre><br/>
Here one important point is we are calling the schedulejob method in init again so this is scheduled for next minute.<br/>
Now if you start this job at some particular time daily let’s say when business start 10 AM in morning, go to schedule job & schedule a job by using this class. That’s it. The job will start on regular time daily & in code we are having a condition when it will stop. So in this way the job will execute from 10 AM to 8 PM daily.<br/>
You can either keep ScheduleJob records for tracking or can delete if not needed. In the above code there is a piece of code which is commented & that is deleting the ScheduleJob object records.<br/><br/>
Happy ending! :)
<br /></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com2tag:blogger.com,1999:blog-5414661301757453099.post-82581155721228657412015-04-30T22:59:00.001-07:002015-04-30T22:59:30.245-07:00Avoid simultaneous update/ Control same record if already opened by someone in edit mode & show a message to end user<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<div dir="ltr" style="text-align: left;" trbidi="on">
Recently I came across a requirement where client wanted to track if any other user also open the same record to edit, in this case he wanted to show a message to second user so he can edit the same record latter.<br/><br/>
To solve this I created a custom setting let’s say Control_Record_Edit__c. Created few other fields to track edit mode –<br/><br/>
Name<br/>
Edit_DateTime__c<br/>
User_Id__c<br/><br/>
Name:- field will save record id which is opened in edit mode by someone.<br/>
Edit_DateTime__c:- field will tell us how long someone open a record in edit mode<br/>
User_Id__c:- field will tell us who open that record in edit mode.<br/><br/><br/>
Now let’s say we want to track lead record. We will create a new VF page that will be called LeadEdit.page.
In this page we will have a function called init which will basically insert a record in our custom setting, so next time whenever someone open the same lead it edit mode we can check in code & show a message that another user is already opened this lead in edit mode.<br/><br/>
<pre class="brush: xml">
<apex:page standardController="lead" extensions="LeadEditController" action="{!init}">
<apex:form id="form1">
<apex:outputPanel rendered="{!isNeedToShowMsg}">
<apex:pageMessages id="error"/>
<apex:commandButton value="Go To Lead" action="/{!objLead.Id}" style="margin-left: 20px;"/>
</apex:outputPanel>
</apex:form>
</apex:page>
</pre><br /><br />
Class code is as below<br />
<pre class="brush:c#">
public with sharing class LeadEditController {
public Lead objLead {get;set;}
public boolean isNeedToShowMsg {get;set;}
public LeadEditController(ApexPages.StandardController stdController){
objLead = (Lead)stdController.getRecord();
}
public PageReference init(){
isNeedToShowMsg = false;
PageReference pr = NULL;
List<Control_Lead_Update__c> listOfControlLeadUpdate = [SELECT Id,User_Id__c,Edit_DateTime__c from Control_Lead_Update__c where Name=:objLead.Id and User_Id__c !=:Userinfo.getUserId() LIMIT 1];
if(listOfControlLeadUpdate != NULL && !listOfControlLeadUpdate.isEmpty()){
List<User> listOfUser = [Select Id, Name from User where Id=:listOfControlLeadUpdate.get(0).User_Id__c LIMIT 1];
if(listOfUser != NULL && !listOfUser.isEmpty()){
String Msg = 'Another User ' + listOfUser.get(0).Name + ' already start editing the same lead at '+ listOfControlLeadUpdate.get(0).Edit_DateTime__c.format() +', Please wait for sometime & click on edit button again!';
ApexPages.Message apexmsg = new ApexPages.Message(ApexPages.Severity.INFO, Msg);
ApexPages.addMessage(apexmsg);
isNeedToShowMsg = true;
}
}else{
Control_Lead_Update__c objControlLead = new Control_Lead_Update__c();
objControlLead.Name = objLead.Id;
objControlLead.Edit_DateTime__c = datetime.now();
objControlLead.User_Id__c = Userinfo.getUserId();
try{
insert objControlLead;
}catch(Exception ex){
system.debug('exception::-->>>' + ex);
}
pr = new PageReference('/' + objLead.Id + '/e?nooverride=1&retURL=/apex/LeadCancel?Id=' + objLead.Id);
}
return pr;
}
public PageReference initCancel(){
LeadHandler.ReleaseEditModeForOthers(new List<Lead>{objLead});
PageReference pr = new PageReference('/' + objLead.Id);
return pr;
}
}
</pre><br/><br/>
Here after this one other issue appear when user click on cancel, if user open a lead & click on cancel we should remove his record from custom setting but the problem is cancel override is not available in salesforce. To handle this we created another page that is called LeadCancel & we are passing it in the retURL parameter.<br/><br/>
<pre class="brush: xml">
<apex:page standardController="lead" extensions="LeadEditController" action="{!initCancel}">
</apex:page>
</pre><br/>
now in the class code there is a method initCancel, that is basically deleting the record from custom setting if a user open a lead & click on cancel button.
also we are passing this cancel page in retuURL parameter so when user click on cancel it will be back to our page.<br/><br/>
There is only one point here which is important, if a user open a lead & close it by browser close button then we can not track that action & in that case no one can edit the same lead until that record does not removed from custom setting.
</div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-54625372779102154342014-08-12T19:44:00.001-07:002014-08-12T20:01:09.229-07:00Small Utilities Method<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
Hi friends, I am back from long time, in between this I could not get a chance to post anything new.<br />
In this post I am showing you small utility methods which we use everyday. This can help if you are looking any quick tip or help -<br />
<pre class="brush:c#">Map<id serrole=""> mapOfUserRole = new Map<id serrole="">([SELECT Id, Name, ParentRoleId FROM UserRole]);
Map<id tring=""> mapOfUserRoleWithHierarchy = new Map<id tring="">();
public void processRoles(){
String level = '';
List<userrole> ListOfUserRole = [SELECT Name, Id FROM UserRole];
if(ListOfUserRole != NULL && ListOfUserRole.Size()>0){
for(UserRole u:ListOfUserRole){
level = processParentRole(u.Id,'');
if(level != ''){
mapOfUserRoleWithHierarchy.put(u.Id,level);
}
}
}
}
public String processParentRole(Id role, String hierarchyString){
UserRole userrole = mapOfUserRole.get(role);
if(userrole.ParentRoleId != NULL){
hierarchyString += '>>' + userrole.Name;
return processParentRole(userrole.ParentRoleId,hierarchyString);
}else{
hierarchyString += '>>'+userrole.Name;
return hierarchyString;
}
}
processRoles();
</userrole></id></id></id></id></pre>
here if you debug mapOfUserRoleWithHierarchy map you will see something like below -
<br />
<pre class="brush:c#">00EXXXXXXXX=>>Team1>>Team2>>Team3>>Team4>>CEO
</pre>
here I am assuming that hierarchy in your system something like
<br />
<pre class="brush: xml"> -CEO
-Team4
-Team3
-Team2
-Team1
</pre>
Hope this can help if you are doing some code & need something related to user role hierarchy!
will keep adding other util method in this post so this can be used kind of quick reference:)
<br />
<br /></div>
</div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-71907454882972830942013-08-07T19:54:00.004-07:002013-08-13T00:28:01.817-07:00How to give a name while export a file in csv/xls<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script><span style="font-family: Trebuchet MS, sans-serif;">
Hi friends, recently I came across a situation where client want's to give a name while exporting a file in csv/xls. In salesforce we can not code in such a way that it will ask you any name before save the file at your local drive. Alternate solution is we can pass different names from the different pages, so we can distinguish in between two exported files from different pages. Here is the detail how you can do this.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">We need to create below resources for it-</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">#1-BlogCSV.page</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">#2-BlogCSV.component</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">#3-BlogCSVController.cls</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">#4-ExportTestPage.page</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">let me take this one by one & tell you how we can pass name while export in this.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>#1-BlogCSV.page </b></span><br />
<span style="font-family: Trebuchet MS, sans-serif;">This is a VF page which generate a xls file for given table.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">here the important thing is we will pass contenttype attribute something like below</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFA1qqRl0bxy8CFwjbH3vE4XuOoMCWNr1I17Aewtb9_a59nTmigxi91buz5CqFcX577dQIgOQXAQi_jMuXUw8CalulN19ToQqa-4ByA4UeUcZeQXHpzxuKETK4Uyh_L0mAbcN5wTTuMF0/s1600/Image1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><span style="font-family: Trebuchet MS, sans-serif;"><img border="0" height="53" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFA1qqRl0bxy8CFwjbH3vE4XuOoMCWNr1I17Aewtb9_a59nTmigxi91buz5CqFcX577dQIgOQXAQi_jMuXUw8CalulN19ToQqa-4ByA4UeUcZeQXHpzxuKETK4Uyh_L0mAbcN5wTTuMF0/s400/Image1.png" width="400" /></span></a></div>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">contentType="application/vnd.ms-excel#{!SUBSTITUTE($CurrentPage.parameters.page,'XXXXXX__','')}_YOUR_POSTFIX_HERE.xls"</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">in this the exported file name will be build by Page Name from where it is exported + your postfix whatever you give in above content type attribute.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">here is the complete code for this-</span><br />
<pre class="brush: xml"><apex:page language="en-US" cache="false" readonly="true" sidebar="false" showHeader="false" pageStyle="false" contentType="application/vnd.ms-excel#{!SUBSTITUTE($CurrentPage.parameters.page,'PackagePrefix__','')}_YOUR_POSTFIX_HERE.xls">
<c:BlogCSV id="csvComponent1" />
</apex:page>
</pre>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>#2-BlogCSV.component</b> </span><br />
<span style="font-family: Trebuchet MS, sans-serif;">this component is simply rendering the account table which will be going to export.</span><br />
<pre class="brush: xml"><apex:component controller="BlogCSVController" id="component1">
<apex:pageBlock >
<apex:pageBlockTable value="{!lstOfAccount}" var="lst" width="100%" rendered="{!IF(lstOfAccount.Size>0,true,false)}">
<apex:column >
<apex:facet name="header" >
Name
</apex:facet>
<apex:outputLink value="{!lst.id}" >{!lst.Name}</apex:outputLink>
</apex:column>
<apex:column >
<apex:facet name="header" >
AccountSource
</apex:facet>
<apex:outputLabel value="{!lst.AccountSource}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:component></pre>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>#3-BlogCSVController.cls</b></span><br />
<span style="font-family: Trebuchet MS, sans-serif;">this class is common controller class for both component & page. here is the code for this -</span><br />
<pre class="brush: c#">public with sharing class BlogCSVController {
public string currentPage {get;set;}
public String redirectURL {get;set;}
public PageReference Export(){
PageReference pr = Page.BlogCSV;
pr.getParameters().put('page',currentPage);
redirectURL = pr.getUrl();
return null;
}
public List<account> lstOfAccount{get;set;}
public BlogCSVController(){
lstOfAccount = [Select Id,Name, AccountSource from Account LIMIT 10];
}
}
</account></pre>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><b>#4-ExportTestPage.page</b></span><br />
<span style="font-family: Trebuchet MS, sans-serif;">finally this is the page where will provide export button which will initiate export.Here is the code-</span><br />
<pre class="brush: xml"><apex:page controller="BlogCSVController">
<apex:form id="form1">
<apex:pageMessages id="msg" />
<apex:sectionHeader Title="Export" subtitle="XLS Sample" />
<apex:pageBlock id="block1">
<apex:pageBlockButtons location="top">
<input type="button" class="btn" value="Export" onclick="Export('{!$CurrentPage.Name}');" />
<apex:actionStatus id="statusLoadingMain">
<apex:facet name="start">
<span style="font-weight:bold; color: red;">
Please wait while exporting...<img src="/img/loading.gif" />
</span>
</apex:facet>
</apex:actionStatus>
</apex:pageBlockButtons>
<script>
function Export(pagename){
jsExport(pagename);
}
</script>
<apex:outputPanel id="pnlExport">
<script>
if("{!redirectURL}" != ""){
window.location.href="{!redirectURL}";
}
</script>
</apex:outputPanel>
<apex:actionFunction status="statusLoadingMain" name="jsExport" action="{!Export}" rerender="pnlExport,msg">
<apex:param name="currentPage" id="currentPage" value="" assignto="{!currentPage}" />
</apex:actionFunction>
</apex:pageBlock>
<c:BlogCSV id="csvComponent1" />
</apex:form>
</apex:page>
</pre>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">here notice that we are passing current page name in action function.</span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;">Now when you click on export this will be exported with your page name & given postfix.</span><br />
<span style="font-family: Trebuchet MS, sans-serif;">You can see a demo <a href="http://kgblog-developer-edition.ap1.force.com/apex/ExportTestPage" target="_blank">here</a></span><br />
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
<span style="font-family: Trebuchet MS, sans-serif;"><br /></span>
</div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com2tag:blogger.com,1999:blog-5414661301757453099.post-26603897285301528092013-02-27T04:24:00.003-08:002013-02-27T04:26:12.428-08:00SOQL Injection<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Hi friends, </span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">While writing dynamic SOQL query, I came to know that we should care about the injection script. I tried to get the way how one can write this kind of script so code starts giving unexpected result. I did a lot of rnd on internet but I found the same sample everywhere which is given in salesforce pdf file, but still I was not getting the practical example that satisfy my SOQL injection doubt. </span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Because of this reason I created a sample to clear my self what is SOQL injection & how this can give you unexpected result. Here I am sharing it with you so you will get an idea what does SOQL injection means.</span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">You can see demo <a href="http://kgblog-developer-edition.ap1.force.com/apex/SOQL" target="_blank">here</a>. There are four buttons in this page. these are quite simple & self explanatory but let me explain in detail if you have any doubt-</span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Button -1 Execute</span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">This button shows how simple dynamic query works if we use Equal comparison</span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br /></span></span>
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Button -2 Execute Like</span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">This button shows how simple dynamic query works if we use LIKE comparison </span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Button -3 Execute Escape</span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">This button show how dynamic query works if we use String.escapeSingleQuotes method in case of equal <span style="font-size: small;">comparison</span></span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Button -4 Execute Like Escape</span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">This button show how dynamic query works if we use String.escapeSingleQuotes method in case of LIKE <span style="font-size: small;">comparison</span> </span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">salesforce <span style="font-size: small;">recommend to use </span></span><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">String.escapeSingleQuotes method i<span style="font-size: small;">f you are writing dynamic query.</span></span></span></span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;">Now </span>If you open this page & enter the text just after the button "Account1' OR name<>'abc" &<span style="font-size: small;"> click on all four buttons & see the output difference. </span></span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;">In the <span style="font-size: small;">f</span>irst two buttons we are not using </span></span><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">escapeSingleQuotes while in the last two buttons we are using </span></span></span><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">escapeSingleQuote<span style="font-size: small;">s method. </span></span></span></span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">here when we gi<span style="font-size: small;">ve injection script </span></span></span></span></span></span>(Account1' OR name<>'abc) first two button show all account in the system, that should not be. while in the last two buttons because we are using <span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">escapeSingleQuotes method that <span style="font-size: small;">does not allow to execute this <span style="font-size: small;">injection script.</span></span></span></span></span><br />
<br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">here is the code of page & class-</span></span></span></span></span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">SOQL.page</span></span></span></span></span></span><br />
<br />
<pre class="brush: xml"><apex:page controller="SOQLController" tabStyle="Account">
<apex:form id="form1">
<apex:pageBlock id="block1">
<apex:inputText value="{!name}" />
<apex:commandButton value="Execute" action="{!Execute}" rerender="pnl" />
<apex:commandButton value="Execute Like" action="{!ExecuteLike}" rerender="pnl" />
<apex:commandButton value="Execute Escape" action="{!ExecuteEscape}" rerender="pnl" />
<apex:commandButton value="Execute Like Escape" action="{!ExecuteLikeEscape}" rerender="pnl" /> <apex:outputLabel value="Account1' OR name<>'abc"></apex:outputLabel>
<apex:outputPanel id="pnl">
<apex:pageBlockTable value="{!lstAccount}" var="lst" id="tbl">
<apex:column value="{!lst.Name}" />
</apex:pageBlockTable>
<apex:pageBlockSection title="Query" columns="1">
<apex:outputLabel value="{!query}" id="qry"/>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
</pre>
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"></span></span></span></span></span></span></span><br />
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;">& class code.. SOQLController.cls</span></span></span></span></span></span></span><br />
<pre class="brush: csharp">
public with sharing class SOQLController {
public List<Account> lstAccount{get;set;}
public string query {get;set;}
public String name {get;set;}
public void Execute(){
String StrName = '=\'' + name + '\'';
query = 'Select Id, Name from Account where name ' + StrName ;
lstAccount = Database.Query(query);
//input -- Account1' OR name<>'xxx
}
public void ExecuteLike(){
String StrName = 'LIKE \'%' + name + '%\'';
query = 'Select Id, Name from Account where name '+ StrName;
lstAccount = Database.Query(query);
}
public void ExecuteEscape(){
String StrName = '=\'' + String.escapeSingleQuotes(name) + '\'';
query = 'Select Id, Name from Account where name ' + StrName;
lstAccount = Database.Query(query);
}
public void ExecuteLikeEscape(){
String StrName = 'LIKE \'%' + String.escapeSingleQuotes(name) + '%\'';
query = 'Select Id, Name from Account where name ' + StrName ;
lstAccount = Database.Query(query);
}
}
</pre>
<span style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"><span style="font-size: small;"> </span></span></span></span></span></span></span></div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-55064891335663354902013-02-21T01:19:00.004-08:002013-02-21T01:19:53.361-08:00Show Star Rating as Salesforce Standard Field<div dir="ltr" style="text-align: left;" trbidi="on">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css"></link>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css"></link>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js" type="text/javascript"></script>
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js" type="text/javascript"></script>
<script language="javascript">
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Hi friends, this time I am coming with a solution for star rating. if you want to show star rating in a standard salesforce layout in form of column.<br />Take a look of below image. in this I am showing some rating as like this is a stanadrd field in salesforce.</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<br /></div>
<div class="separator" style="clear: both; font-family: "Trebuchet MS",sans-serif; text-align: center;">
<span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6csVQ0QoOliFwlOJt27jMY_oAhkYr3VsFvFEOJzuCrHfhOYHkZ5ZIHkd2NklNzxztKUz9GyTXvVohyphenhyphenruBUQctO_g5kMpsYKI7Sex2tlrZjVpChnL4Clyk6LYkRXyVKPAnki0aKAU2LkY/s1600/Untitled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="173" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6csVQ0QoOliFwlOJt27jMY_oAhkYr3VsFvFEOJzuCrHfhOYHkZ5ZIHkd2NklNzxztKUz9GyTXvVohyphenhyphenruBUQctO_g5kMpsYKI7Sex2tlrZjVpChnL4Clyk6LYkRXyVKPAnki0aKAU2LkY/s400/Untitled.png" width="400" /></a></span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<br /></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">In above image notice that you rating field is appear same as standard field on UI. here is how you can do this-</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Step-1</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Create a new page named "StarRating" & a new controller class "StarRatingController" in salesforce.</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;"><br /></span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Step-2</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Get a jquery star plugin files from net & upload these files in salesforce static resource. I will also tell you the path one of my page latter from where you can download these files.</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;"><br /></span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Step-3</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">I assuming that you uploaded two static resource -</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">a-OrgResource</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">b-jQueryStarRatingPlugIn</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;"><br /></span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">in first zip file we are having all jquery js & css files. although we are going to use few of them.</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">second one zip file is having all files which we downloaded from jquery plugin site.</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;"><br /></span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Step-4</span></div>
<div style="font-family: "Trebuchet MS",sans-serif;">
<span style="font-size: small;">Copy & paste below code in VF page</span><br />
<pre class="brush: xml"><apex:page id="page1" sidebar="false" showHeader="false" standardController="Account" extensions="StarRatingController">
<apex:styleSheet value="{!URLFOR($Resource.OrgResource,'development-bundle/themes/base/jquery.ui.all.css')}" />
<apex:styleSheet value="{!URLFOR($Resource.jQueryStarRatingPlugIn,'jquery.ui.stars.css')}" />
<apex:includeScript value="{!URLFOR($Resource.OrgResource,'js/jquery-1.5.1.js')}" />
<apex:includeScript value="{!URLFOR($Resource.OrgResource,'development-bundle/ui/jquery.ui.core.js')}" />
<apex:includeScript value="{!URLFOR($Resource.OrgResource,'development-bundle/ui/jquery.ui.widget.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jQueryStarRatingPlugIn,'jquery.ui.stars.min.js')}" />
<style>
.detailList{
width:94%;
}
.pbBody, .pbBody a, .pbBody td, .lbBody a, .lbBodyDescription, .list .headerRow .noRowsHeader {
border-bottom: 0 none !important;
}
</style>
<apex:form id="form1">
<apex:pageBlock >
<div id="ep" class="bDetailBlock bPageBlock secondaryPalette">
<div class="pbSubsection">
<table cellspacing="0" cellpadding="0" border="0" class="detailList" style="border-bottom:none !important;" >
<tbody>
<tr>
<td class="labelCol">Rating</td>
<td class="dataCol col02">
<apex:outputPanel >
<div class="divRating">
<apex:selectList value="{!rating}" size="1">
<apex:selectOptions value="{!listOfRatingOptions}" />
</apex:selectList>
</div>
</apex:outputPanel>
</td>
<td class="labelCol">&nbsp;</td>
<td class="dataCol col02">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>
<script>
jQuery(document).ready(function(){
jQuery(".divRating").stars({
inputType: "select",
cancelShow: false,
disabled:true
});
$(".accountBlock").children().attr('class','');
$(".detailList").css('width','94%');
});
</script>
</apex:pageBlock>
</apex:form>
</apex:page></pre>
Step-5
Copy & paste below class code in controller which you create few steps back
<br />
<pre class="brush: csharp">public with sharing class StarRatingController {
public integer rating {get;set;}
public List<SelectOption> listOfRatingOptions {get;set;}
public StarRatingController(ApexPages.StandardController controller){
listOfRatingOptions = new List<SelectOption>();
rating = 3;
string val = '';
for(integer i=1;i<=5;i++){
val = string.valueOf(i);
listOfRatingOptions.add(new SelectOption(val,val));
}
}
}</pre>
now you can include this page in account stadarad layout. To add this follow next steps.<br />
<br />
Step-6<br />
Click on account tab, this will show you list of account. Open one account & click on Edit Layout link at top left.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5qDCpq-gKVw2sQtr5EynQjE_KnNEq__myh-f_vPC8lp-OgEah3rAtPdAJiqXg9ZRCvJPKQyzj11mmWk_ZiswWHUbuLi8lmj481K7PoYh-FQ9Eee1nzsZ-p-nBYDV221ui7lzM6YuGP_0/s1600/Untitled2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5qDCpq-gKVw2sQtr5EynQjE_KnNEq__myh-f_vPC8lp-OgEah3rAtPdAJiqXg9ZRCvJPKQyzj11mmWk_ZiswWHUbuLi8lmj481K7PoYh-FQ9Eee1nzsZ-p-nBYDV221ui7lzM6YuGP_0/s400/Untitled2.png" width="400" /></a></div>
Step-7<br />
Add a new section from the layout. Give any name to this section.Uncheck Display Section Header On two check box (Detail page & Edit page). In Layout option select 1-Column option & click on save.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrpPmAor3Zbhqm9Uhl6YUatfryt7XRmBPexdgcrsaTom9kkCST5Uv0iXoY9IeGh9nUpkNAbXHLrjsKf1WOYc1_TAZu2BtaXWq7c7tbbZblpfLoTKajwN162cmCcGyUBVeWI1R_pdpTRmA/s1600/Untitled3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="185" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrpPmAor3Zbhqm9Uhl6YUatfryt7XRmBPexdgcrsaTom9kkCST5Uv0iXoY9IeGh9nUpkNAbXHLrjsKf1WOYc1_TAZu2BtaXWq7c7tbbZblpfLoTKajwN162cmCcGyUBVeWI1R_pdpTRmA/s400/Untitled3.png" width="400" /></a></div>
<br />
Step-8<br />
Add starRating VF page to this section & set height 20 & width 100%.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlPXXGttcI8Zm1lprQtSp6bZmilf0r4RBL-PwvBTZuk-Xi3JT69t4pYcYJZvG_Cbx-7rgPFQMX51_njc0iRBSzyTw4roPuflMrPlYruvqzPe2LL-eCb0uHS2_iyZb8gNkZ8aWGY4n9Mnk/s1600/Untitled4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlPXXGttcI8Zm1lprQtSp6bZmilf0r4RBL-PwvBTZuk-Xi3JT69t4pYcYJZvG_Cbx-7rgPFQMX51_njc0iRBSzyTw4roPuflMrPlYruvqzPe2LL-eCb0uHS2_iyZb8gNkZ8aWGY4n9Mnk/s400/Untitled4.png" width="400" /></a> </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Save layout & see that rating is available same as a standard field on account detail.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<a href="http://kgblog-developer-edition.ap1.force.com/apex/StarRating" target="_blank">here</a> is the link of star rating page if you want to see how this looks like.You can also download the static resource files by view source.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
The same thing you can also do on any VF page. here is <a href="http://kgblog-developer-edition.ap1.force.com/apex/SiteStarRating" target="_blank">demo</a> page. the code of this demo page is as below-</div>
<pre class="brush: xml"><apex:page standardController="Account" extensions="SiteStarRatingController" id="page1">
<apex:sectionHeader title="Site" subTitle="Star Rating Sample" />
<apex:pageBlock id="block1">
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Account Name" />
<apex:outputField value="{!act.Name}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1">
<apex:iframe src="/apex/StarRating" height="20px" />
</apex:pageBlockSection>
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Type" />
<apex:outputField value="{!act.Type}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Description" />
<apex:outputField value="{!act.Description}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Fax" />
<apex:outputField value="{!act.Fax}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page></pre>
controller class is as below-
<br />
<pre class="brush: csharp">public with sharing class SiteStarRatingController {
public Account act{get;set;}
public SiteStarRatingController(ApexPages.StandardController controller){
act = [Select Id,Name,Type, Industry, Fax, Description from Account limit 1];
}
}</pre>
Done..!! :)
</div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com10tag:blogger.com,1999:blog-5414661301757453099.post-74790709968978913392012-08-12T20:47:00.001-07:002012-08-12T20:59:16.471-07:00Salesforce Deployment - Delete a file through ANT<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
</div>
I usually use the ant for deployment this is easy to use
& also take less time then Eclipse deployment. Recently I required to delete a resource from some
salesforec org, & I found that there is no detail mentioned about this
topic on internet. I keep digging this & come with the detail how you can
delete a resource by ANT.<br />
When we use ant deployment here is the folder hierarchy which
we use-<br />
ANT Sample Folder<br />
>>mypkg
Folder<br />
>>retrieveUnpackaged
Folder<br />
>> removecodepkg Folder [Create
this new folder to delete the files]<br />
>>build.properties
files<br />
>>build.xml<br />
<br />
To delete a resource you need to add a <span style="font-family: "ACaslon-Regular","sans-serif"; line-height: 115%;">destructiveChanges.xml</span> file in removecodepkg folder. The <span style="font-family: "ACaslon-Regular","sans-serif"; line-height: 115%;">destructiveChanges.xml file is same as package.xml. format of
this file is as below-</span><br />
<span style="font-family: "ACaslon-Regular","sans-serif"; line-height: 115%;"><br /><o:p></o:p></span><span style="color: blue;"><?xml version="1.0" encoding="UTF-8"?></span><br />
<span style="color: blue;"><Package xmlns="http://soap.sforce.com/2006/04/metadata"></span><br />
<span style="color: blue;"> <types></span><br />
<span style="color: blue;"> <members>LoginController</members></span><br />
<span style="color: blue;"> <members>LoginControllerTest</members></span><br />
<span style="color: blue;"> <name>ApexClass</name></span><br />
<span style="color: blue;"> </types> </span><br />
<span style="color: blue;"> <version>19.0</version></span><br />
<span style="color: blue;"></Package></span><br />
<br />
You also need to have a blank package.xml file in the same removecodepkg
folder. Format of the file will be-<br />
<br />
<span style="color: blue;"><?xml version="1.0" encoding="UTF-8"?></span><br />
<span style="color: blue;"><Package xmlns="http://soap.sforce.com/2006/04/metadata"></span><br />
<span style="color: blue;"> <version>19.0</version></span><br />
<span style="color: blue;"></Package></span><br />
<br />
Now you have two xml files in removecodepkg folder –<br />
1-destructiveChanges.xml <br />
<span style="text-indent: -18pt;"> <span style="font-family: inherit;">2-package.xml</span></span><br />
<span style="text-indent: -18pt;"> </span><br />
ant is having build.xml file which
have all commands can be executed. There will be a command to delete the code-<br />
<target name="undeployCode"></target><br />
<span style="color: blue;"><target name="undeployCode"></span><br />
<br />
<span style="color: blue;"> <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="removecodepkg"/></span><br />
<span style="color: blue;"> </target></span><br />
<br />
<sf:deploy deployroot="removecodepkg" password="${sf.password}" serverurl="${sf.serverurl}" username="${sf.username}"> </sf:deploy><br />
Now mention the name of the
resource in <span style="font-family: "ACaslon-Regular","sans-serif"; line-height: 115%;">destructiveChanges.xml</span> file & delete the file from destination
org. in our example I am deleting a class LoginController & it’s test
class.<br />
You just need to execute below
command on ant<br />
>>ant undeployCode<br />
<br />
<h2>
<div style="text-align: left;">
<br /></div>
</h2>
</div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com1tag:blogger.com,1999:blog-5414661301757453099.post-72777040240744305912012-08-12T10:41:00.000-07:002012-08-12T11:02:39.171-07:00Partner Portal Login Page Customization & URL Masking for Partner Portal<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
Hope you are totally aware about the partner portal &
site before going through this post. In the partner portal salesforce
internally provide the default login page that is not user friendly.
Here are some issues with the default portal login page-</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#1-If you want to do some customization on the page like
position, styles etc than it will a little bit difficult. Although you can use
header & footer to add the custom style but there is some limitation if you
want to fully customize this login box.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#2-Salesforce provide some default url for portal that is not user friendly. It will be something like as below</div>
<div class="MsoNormal">
<a href="https://cs14.salesforce.com/secur/login_portal.jsp?orgId=XXXXXXXXX&portalId=XXXXXXXXX">https://XXX.salesforce.com/secur/login_portal.jsp?orgId=XXXXXXXXX&portalId=XXXXXXXXX</a></div>
<div class="MsoNormal">
The url looks not good & not easy to remember if you want to spread to the portal users.<br />
<br /></div>
<div class="MsoNormal">
#3-Probably customer required branding at home page & in
that case customize login page is a good option.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
To avoid these issues you can create a custom login page
& can also use site for URL masking (for any partner portal which in the same org). here is the steps </div>
<div class="MsoNormal">
by which you can do this-</div>
<div class="MsoNormal">
#1-Hope you already having a partner portal in your org.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#2-Create a new site by registering a domain for that org.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
let's say you rgister a site with below domain - </div>
<div class="MsoNormal">
SitePortal so you site url will be
http://SitePortal-developer-edition.ap1.force.com</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#3-Create a dummy login VF page (Name - VFPortalLogin) for
now, leave it blank, we will use this page in next step.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#4-Now go to Setup--> Site</div>
<div class="MsoNormal">
create a site with some label. let's say you create MySite.
So your site address will be</div>
<div class="MsoNormal">
http://SitePortal-developer-edition.ap1.force.com/MySite</div>
<div class="MsoNormal">
set the step #3 PortalLogin page as the default page</div>
<div class="MsoNormal">
give the access to site as well as portal for this new page.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
#5-Go to Setup--> Site --> Click on recently
registered site --> click on Login Setting</div>
<div class="MsoNormal">
Enable the Login (check the checkbox) for the partner which
we created at first.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
now open that page by site url, your url will be something
like</div>
<div class="MsoNormal">
http://SitePortal-developer-edition.ap1.force.com/MySite OR</div>
<div class="MsoNormal">
http://SitePortal-developer-edition.ap1.force.com/MySite/PartnerLogin</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
you will see that blank login page which we created in previous steps. Upto this step notice that we are using the url masking for the portal. now we are going to start in
the code part. here is the login VF page code, copy this code & paste in
your VF page</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:page</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">sidebar</span>=<i><span style="color: #2a00ff;">"false"</span></i>
<span style="color: #7f007f;">showHeader</span>=<i><span style="color: #2a00ff;">"false"</span></i> <span style="color: #7f007f;">controller</span>=<i><span style="color: #2a00ff;">"PortalLoginController"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:form</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">forceSSL</span>=<i><span style="color: #2a00ff;">"true"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:styleSheet </span><span style="color: #7f007f; font-family: "Courier New"; font-size: 9.0pt;">value</span><span style="font-family: 'Courier New'; font-size: 9pt;">=</span><i><span style="color: #2a00ff; font-family: "Courier New"; font-size: 9.0pt;">"{!URLFOR($Resource.PortalResource,'/PortalCSS/elements.css')}"</span></i><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:styleSheet</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">"{!URLFOR($Resource.</span></i></span><i><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 9pt;">Portal</span></i><i style="font-family: 'Courier New'; font-size: 9pt;"><span style="color: #2a00ff;">Resource,'/PortalCSS/common.css')}"</span></i><span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: 'Courier New'; font-size: 9pt;">/></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:styleSheet</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">"{!URLFOR($Resource.</span></i></span><i><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 9pt;">Portal</span></i><i style="font-family: 'Courier New'; font-size: 9pt;"><span style="color: #2a00ff;">Resource,'/PortalCSS/extended.css')}"</span></i><span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: 'Courier New'; font-size: 9pt;">/></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:styleSheet</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">"{!URLFOR($Resource.</span></i></span><i><span style="color: #2a00ff; font-family: 'Courier New'; font-size: 9pt;">Portal</span></i><i style="font-family: 'Courier New'; font-size: 9pt;"><span style="color: #2a00ff;">Resource,'/PortalCSS/portal.css')}"</span></i><span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: 'Courier New'; font-size: 9pt;">/></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">style</span><span style="font-family: "Courier New"; font-size: 9.0pt;">
<span style="color: #7f007f;">type</span>=<i><span style="color: #2a00ff;">"text/css"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 9.0pt;">
.username, .pw {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 9.0pt;">
width: 175px;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 9.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: teal;"></</span><span style="color: #3f7f7f;">style</span><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:pageMessages</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">id</span>=<i><span style="color: #2a00ff;">"msg"</span></i> <span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">style</span>=<i><span style="color: #2a00ff;">"margin-top:60px;"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"portalheaderPRM"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">style</span>=<i><span style="color: #2a00ff;">"width: 400px;
margin: 0px auto; text-align: center; padding-right: 66px; padding-bottom:
10px; padding-top: 10px; margin-bottom: 10px;"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> Put your <span style="color: #3f5fbf;">LOGO </span></span><span style="font-family: 'Courier New'; font-size: 12px;">here</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">style</span>=<i><span style="color: #2a00ff;">"margin: 0px
auto; width: 400px;"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">id</span>=<i><span style="color: #2a00ff;">"loginBox"</span></i>
<span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"bPageBlock"</span></i> <span style="color: #7f007f;">border</span>=<i><span style="color: #2a00ff;">"0"</span></i> <span style="color: #7f007f;">cellpadding</span>=<i><span style="color: #2a00ff;">"0"</span></i>
<span style="color: #7f007f;">cellspacing</span>=<i><span style="color: #2a00ff;">"0"</span></i> <span style="color: #7f007f;">width</span>=<i><span style="color: #2a00ff;">"85%"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">valign</span>=<i><span style="color: #2a00ff;">"top"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">input</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">type</span>=<i><span style="color: #2a00ff;">"hidden"</span></i>
<span style="color: #7f007f;">name</span>=<i><span style="color: #2a00ff;">"startURL"</span></i> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">""</span></i>
<span style="color: teal;">/></span> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbHeader"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">border</span>=<i><span style="color: #2a00ff;">"0"</span></i>
<span style="color: #7f007f;">cellpadding</span>=<i><span style="color: #2a00ff;">"0"</span></i> <span style="color: #7f007f;">cellspacing</span>=<i><span style="color: #2a00ff;">"0"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbTitle"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">h2</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: 'Courier New'; font-size: 9pt;">Secure Customer
Login</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">h2</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbBody"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">border</span>=<i><span style="color: #2a00ff;">"0"</span></i>
<span style="color: #7f007f;">cellpadding</span>=<i><span style="color: #2a00ff;">"0"</span></i> <span style="color: #7f007f;">cellspacing</span>=<i><span style="color: #2a00ff;">"0"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"portalLoginLabel"</span></i><span style="color: teal;">><</span><span style="color: #3f7f7f;">label</span> <span style="color: #7f007f;">for</span>=<i><span style="color: #2a00ff;">"username"</span></i><span style="color: teal;">></span>User Name:<span style="color: teal;"></</span><span style="color: #3f7f7f;">label</span><span style="color: teal;">></</span><span style="color: #3f7f7f;">td</span><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:inputText</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">"{!UserId}"</span></i> <span style="color: #7f007f;">Styleclass</span>=<i><span style="color: #2a00ff;">"username"</span></i>
<span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"portalLoginLabel"</span></i><span style="color: teal;">><</span><span style="color: #3f7f7f;">label</span> <span style="color: #7f007f;">for</span>=<i><span style="color: #2a00ff;">"password"</span></i><span style="color: teal;">></span>Password:<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">label</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:inputSecret</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">"{!UserPassword}"</span></i> <span style="color: #7f007f;">Styleclass</span>=<i><span style="color: #2a00ff;">"pw"</span></i>
<span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">a</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">id</span>=<i><span style="color: #2a00ff;">"forgotPassword"</span></i>
<span style="color: #7f007f;">href</span>=<i><span style="color: #2a00ff;">"/XXX_PortalPrefix/apex/PortalForgotPasswordVF"</span></i><span style="color: teal;">></span>Forgot your password?<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">a</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbBottomButtons"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">border</span>=<i><span style="color: #2a00ff;">"0"</span></i>
<span style="color: #7f007f;">cellpadding</span>=<i><span style="color: #2a00ff;">"0"</span></i> <span style="color: #7f007f;">cellspacing</span>=<i><span style="color: #2a00ff;">"0"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbTitle"</span></i><span style="color: teal;">><</span><span style="color: #3f7f7f;">img</span> <span style="color: #7f007f;">width</span>=<i><span style="color: #2a00ff;">"1"</span></i> <span style="color: #7f007f;">height</span>=<i><span style="color: #2a00ff;">"1"</span></i>
<span style="color: #7f007f;">title</span>=<i><span style="color: #2a00ff;">""</span></i> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"minWidth"</span></i>
<span style="color: #7f007f;">alt</span>=<i><span style="color: #2a00ff;">""</span></i> <span style="color: #7f007f;">src</span>=<i><span style="color: #2a00ff;">"/s.gif"</span></i>
<span style="color: teal;">/></</span><span style="color: #3f7f7f;">td</span><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbButtonb"</span></i><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:commandButton</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">value</span>=<i><span style="color: #2a00ff;">"Login"</span></i>
<span style="color: #7f007f;">action</span>=<i><span style="color: #2a00ff;">"{!login}"</span></i> <span style="color: teal;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #3f5fbf; font-family: "Courier New"; font-size: 9.0pt;"></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="font-family: "Courier New"; font-size: 9.0pt;"> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"pbFooter
secondaryPalette"</span></i><span style="color: teal;">><</span><span style="color: #3f7f7f;">div</span> <span style="color: #7f007f;">class</span>=<i><span style="color: #2a00ff;">"bg"</span></i><span style="color: teal;">></</span><span style="color: #3f7f7f;">div</span><span style="color: teal;">></</span><span style="color: #3f7f7f;">div</span><span style="color: teal;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">td</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">tr</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">table</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">div</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt;">apex:form</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt;">></span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: teal; font-family: "Courier New"; font-size: 9.0pt; line-height: 115%;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 9.0pt; line-height: 115%;">apex:page</span><span style="color: teal; font-family: "Courier New"; font-size: 9.0pt; line-height: 115%;">></span></div>
</div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<br />
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
you see that there are some resource used in the page. you
can download these resource from the partner portal default login page>> view
source. save all four CSS in a folder & upload it in static resource. set
the path in the VF page as per your folder hierarchy.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
now here is the controller code for that login page -</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">class</span></b><span style="font-family: 'Courier New'; font-size: 9pt;">
PortalLoginController {</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 9pt;"> String UserId
{get;</span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">set</span></b><span style="font-family: 'Courier New'; font-size: 9pt;">;}</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 9pt;"> String UserPassword {get;</span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">set</span></b><span style="font-family: 'Courier New'; font-size: 9pt;">;}</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 9pt;">
PortalLoginController(){</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> }</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">public</span></b><span style="font-family: 'Courier New'; font-size: 9pt;"> PageReference
login(){</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> PageReference
pr = </span><span style="color: #2218e6; font-family: "Courier New"; font-size: 9.0pt;">Site</span><span style="font-family: 'Courier New'; font-size: 9pt;">.login(UserId, UserPassword, </span><span style="color: green; font-family: "Courier New"; font-size: 9.0pt;">'/apex/PortalHomepage'</span><span style="font-family: 'Courier New'; font-size: 9pt;">);</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><b><span style="color: #7f0055; font-family: "Courier New"; font-size: 9.0pt;">return</span></b><span style="font-family: 'Courier New'; font-size: 9pt;"> pr;</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> }</span><span style="font-family: "Courier New"; font-size: 9.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;">}</span></div>
<br />
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Create a new VF page & set it's name in controller so
user will be redirect on that home page after logged in. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
It's done, now you see that you can use a custom url for you
portal, means we have done url masking.</div>
<div class="MsoNormal">
whenever you need to add a new page you just need to add it
at portal & you can use that with the same masked url..!! </div>
<br />
<br /></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com9tag:blogger.com,1999:blog-5414661301757453099.post-37114435270302524762012-05-30T05:09:00.001-07:002012-05-30T06:09:54.527-07:00JS Remoting in Salesforce with Mustache<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: inherit;"><br /></span><br />
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">Js
remoting is very useful & interesting feature. By this the page
is not posted back to server & you will get result in less than a
second...!!!</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">let's
start with an example how this works. I am also going to use
Mustache.js template in the VF page. Mustache is a js templates &
can be used if you want to generate the html dynamically. It means
you will define the template first & the data will be rendered as
per the defined templates.</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">To
know more about mustache you can check below url</span></div>
<div style="margin-bottom: 0in;">
<span style="color: black;"><span lang="en-US" style="font-family: inherit;"><a href="https://github.com/janl/mustache.js">https://github.com/janl/mustache.js</a>
or</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"><span lang="en-US"><a href="http://mustache.github.com/">http://mustache.github.com/</a>
</span></span>
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">to
implement the js remoting first we need to create a controller class
in apex.</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">Please
notice that the </span><span style="color: #3f7f7f;">apiVersion</span><span style="color: black;">
for controller class must be 23 or above.</span></span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><br /></span></div>
<div lang="en-US" style="margin-bottom: 0in;">
</div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>class</b></span><span style="color: black;">
JSremotingController {</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> </span><span style="color: teal;">@RemoteAction</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper getOuterWrapperObject(string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> return
null;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: teal;"> @RemoteAction</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper setOuterWrapperObject(String jsonString, string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> return
null</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: #7f0055; font-family: inherit;"><b><br /></b></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> </span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>class</b></span><span style="color: black;">
InnerWrapper{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
string name {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
string description {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
InnerWrapper(String strName, String strDesceription){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> this</b></span><span style="color: black;">.name
= strName;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> this</b></span><span style="color: black;">.description
= strDesceription;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> </span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>class</b></span><span style="color: black;">
OuterWrapper{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
String oppName {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
String oppDescription {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> public</b></span><span style="color: black;"> </span></span><span style="color: black;"><innerwrapper>List<InnerWrapper> listOfInnerWrapper<span style="font-family: inherit;"> {get;</span></innerwrapper></span><span style="color: #7f0055; font-family: inherit;"><b>set</b></span><span style="color: black; font-family: inherit;">;}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;"> </span></span><span style="color: black;"><string>List<String> listOfStr_SelectOptions<span style="font-family: inherit;"> {get;</span></string></span><span style="color: #7f0055; font-family: inherit;"><b>set</b></span><span style="color: black; font-family: inherit;">;}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
OuterWrapper(</span><span style="color: #2218e6;">Opportunity</span><span style="color: black;">
o){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfStr_SelectOptions
= SelectOptions_Global;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfInnerWrapper
= </span><span style="color: #7f0055; font-family: inherit;"><b>new</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><innerwrapper>List<InnerWrapper>()<span style="font-family: inherit;">;</span></innerwrapper></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> oppName
= o.</span><span style="color: #2218e6;">Name</span><span style="color: black;">;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> oppDescription
= o.Description;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">let's
dig the code step by step-</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal; font-family: inherit;">@RemoteAction</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal; font-family: inherit;"><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper getOuterWrapperObject(string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal;"><span style="color: black; font-family: inherit;">}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal; font-family: inherit;"><span style="color: black;">this
method is defined as remote action by </span>@RemoteAction <span style="color: black;">tag</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal;"><span style="color: black; font-family: inherit;">it
must be declared with global & static keyword because the
function is related to class instance. It will be called by js
remoting to get the data on VF page.</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal; font-family: inherit;">@RemoteAction</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal; font-family: inherit;"><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper setOuterWrapperObject(string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal;"><span style="color: black; font-family: inherit;">}</span></span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">this
method is same as above just the difference is we will use this to
update the opportunity description.</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"><span lang="en-US">There
are two wrapper class. One is main class & other class list used
in main class. The reason why I took this wrapper class structure to
explain how we can </span></span><span style="color: black;">deserialize</span><span style="color: black;"><span lang="en-US">
the input (json string) directly to wrapper class.</span></span></span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">Now
again taking the implementataion part for the methods-</span></div>
<span style="font-family: inherit;"><br /></span><br />
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: teal; font-family: inherit;"><u>@RemoteAction</u></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper getOuterWrapperObject(string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #2218e6;"> Opportunity</span><span style="color: black;">
opp = [</span><span style="color: #7f0055;"><b>Select</b></span><span style="color: black;">
o.</span><span style="color: #2218e6;">Name</span><span style="color: black;">,
o.Id, o.Description </span><span style="color: #7f0055;"><b>From</b></span><span style="color: black;"> </span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: #2218e6;"> Opportunity</span><span style="color: black;">
o </span><span style="color: #7f0055;"><b>WHERE</b></span><span style="color: black;">
Id=:oppId];</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> OuterWrapper
objOuterWrapper = <span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
OuterWrapper(Opp);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> </span>List<InnerWrapper> <innerwrapper style="font-family: inherit;">WrapperT = </innerwrapper><span style="color: #7f0055; font-family: inherit;"><b>new</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><innerwrapper>List<InnerWrapper><span style="font-family: inherit;">();</span></innerwrapper></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfInnerWrapperT.add(<span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
InnerWrapper(</span><span style="color: green;">'TEST1'</span><span style="color: black;">,</span><span style="color: green;">'DESC1'</span><span style="color: black;">));</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> objOuterWrapper.listOfInnerWrapper
= listOfInnerWrapperT;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> return</b></span><span style="color: black;">
objOuterWrapper;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
}</span></div>
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><br /></span></div>
<div lang="en-US" style="margin-bottom: 0in;">
</div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">in
this method we will pass a opp od from the VF page, the code will get
the detail from the database create wrapper & return this.</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">In
JS we will get a js object of OuterWrapper, we can directly access
it's field same as we get the value we get in javascript code. You
will get it more clearly as I will add the vf page in nect couple of
lines.</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: teal;">@RemoteAction</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper setOuterWrapperObject(String jsonString, string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> OuterWrapper
objOuterWrapper = </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> (OuterWrapper)System.JSON.deserialize(jsonString,OuterWrapper.Class);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #2218e6;"> Opportunity</span><span style="color: black;">
opp = </span><span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
</span><span style="color: #2218e6;">Opportunity</span><span style="color: black;">(Id=oppId);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> opp.Description
= objOuterWrapper.oppDescription;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> update</b></span><span style="color: black;">
opp;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> return</b></span><span style="color: black;">
objOuterWrapper;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">this
method simply updateting the opp description. This method will be
called from the VF page buttton.</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">Now
let's move on the VF page detail-</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br />
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">first
of all you need to include the js files for this. There are two js
files-</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><apex:includescript value="{!URLFOR($Resource.JS,'jquery-1.4.2.min.js')}" /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><apex:includescript value="{!URLFOR($Resource.JS,'mustache.js')}" /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">I
have to include these files because I am using the mustache in the
page, you can avoid this if not required.</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: #7f0055;"><b>function</b></span><span style="color: black;">
getOuterWrapperObjectByJSRemoting(oppId) {</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> JSremotingController.getOuterWrapperObject(oppId,
<span style="color: #7f0055;"><b>function</b></span><span style="color: black;">(result,
event){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> if</b></span><span style="color: black;">
(event.status) {</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> result_Global=
result;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> var</b></span><span style="color: black;">
template = </span><span style="color: #2a00ff;">"</span><span style="color: #2a00ff;"><b><span>Opportunity Name:</span> {{oppName}}</b><br/><br/><span>Opportunity Description</span> {{oppDescription}}</span><span style="color: #2a00ff;">"</span><span style="color: black;">;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> var</b></span><span style="color: black;">
html = Mustache.to_html(template, result);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> $(</span><span style="color: #2a00ff;">'#SPANOppName'</span><span style="color: black;">).html(html);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span>
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> }
<span style="color: #7f0055;"><b>else</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>if</b></span><span style="color: black;">
(event.type === </span><span style="color: #2a00ff;">'exception'</span><span style="color: black;">)
{ </span></span>
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> alert(<span style="color: #2a00ff;">"exception"</span><span style="color: black;">);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> document.getElementById(<span style="color: #2a00ff;">"responseErrors"</span><span style="color: black;">).innerHTML
= event.message;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> } </span><span style="color: #7f0055;"><b>else</b></span><span style="color: black;">
{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> alert(</span><span style="color: #2a00ff;">"else"</span><span style="color: black;">);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> document.getElementById(</span><span style="color: #2a00ff;">"responseErrors"</span><span style="color: black;">).innerHTML
= event.message;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
},
{escape:<span style="color: #7f0055;"><b>true</b></span><span style="color: black;">});</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">by
this js method we will pass a opp id & will get the detail in
jsObject result. You can check/run result_Global on the console to
check the structure of the js object.</span></div>
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<div>
<span style="font-family: inherit;"><br /></span></div>
<div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: #7f0055;"><b>function</b></span><span style="color: black;">
SetOuterWrapperObjectByJSRemoting(jsonString, oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> JSremotingController.setOuterWrapperObject(jsonString,
oppId, </span><span style="color: #7f0055;"><b>function</b></span><span style="color: black;">(result,
event){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> if</b></span><span style="color: black;">
(event.status) {</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> result_Global2 = result;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> alert(</span><span style="color: #2a00ff;">'updated..!!'</span><span style="color: black;">);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> }
</span><span style="color: #7f0055;"><b>else</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>if</b></span><span style="color: black;">
(event.type === </span><span style="color: #2a00ff;">'exception'</span><span style="color: black;">)
{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> alert(</span><span style="color: #2a00ff;">"exception"</span><span style="color: black;">);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> document.getElementById(</span><span style="color: #2a00ff;">"responseErrors"</span><span style="color: black;">).innerHTML
= event.message;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> }
</span><span style="color: #7f0055;"><b>else</b></span><span style="color: black;">
{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> alert(</span><span style="color: #2a00ff;">"else"</span><span style="color: black;">);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> document.getElementById(</span><span style="color: #2a00ff;">"responseErrors"</span><span style="color: black;">).innerHTML
= event.message;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> },
{escape:<span style="color: #7f0055;"><b>true</b></span><span style="color: black;">});</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">this
method simply udate the opp description by js remoting.</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>function</b></span><span style="color: black;">
getJSONObject(){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
<span style="color: #3f7f5f;">//Outer Wrapper</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>var</b></span><span style="color: black;">
objOpportunityWrapper = </span><span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
Object();</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
objOpportunityWrapper[<span style="color: #2a00ff;">"oppDescription"</span><span style="color: black;">]
= $(</span><span style="color: #2a00ff;">"#inputOppDescription"</span><span style="color: black;">).val();</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span>
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>var</b></span><span style="color: black;">
InnerWrapper = </span><span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
Object();</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>var</b></span><span style="color: black;">
InnerWrapperArray = </span><span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
Array();</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
InnerWrapper[<span style="color: #2a00ff;">"name"</span><span style="color: black;">]
= </span><span style="color: #2a00ff;">'TEST Name1'</span><span style="color: black;">;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
InnerWrapper[<span style="color: #2a00ff;">"description"</span><span style="color: black;">]
= </span><span style="color: #2a00ff;">'TEST Description1'</span><span style="color: black;">;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
InnerWrapperArray[0]
= InnerWrapper;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
objOpportunityWrapper[<span style="color: #2a00ff;">"listOfInnerWrapper"</span><span style="color: black;">]
= InnerWrapperArray;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
JSON_STR
= JSON.stringify(objOpportunityWrapper);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
SetOuterWrapperObjectByJSRemoting(JSON_STR,Opp_Id);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">I
think this is the most important method on the js. this method is
going to create structure same as the wrapper class. it there is any
difference in between the object you created on JS & controller
class than the json string will not be serialized in controller.</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">let's
put the whole code in one place-</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">class
code will be
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>class</b></span><span style="color: black;">
JSremotingController {</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"></span><span style="color: #7f0055; font-family: inherit;"><b> private</b></span><span style="color: black; font-family: inherit;">
</span><span style="color: #7f0055; font-family: inherit;"><b>static</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><string>List<String><span style="font-family: inherit;"> SelectOptions_Global = </span></string></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> getFieldDescibe(</span><span style="color: #2218e6;">Opportunity</span><span style="color: black;">.LeadSource.getDescribe());</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> </b></span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: #7f0055;"><b>public</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
List<string> getFieldDescibe(Schema.DescribeFieldResult Res){</string></span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black;"><span style="font-family: inherit;"> </span><string>List<String> <span style="font-family: inherit;">listOfOpt = </span></string><span style="color: #7f0055; font-family: inherit;"><b>new</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><string>List<String><span style="font-family: inherit;">();</span></string></span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black;"><span style="font-family: inherit;"> </span><schema.picklistentry>List<Schema.PicklistEntry><span style="font-family: inherit;"> pe = Res.getPicklistValues();</span></schema.picklistentry></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> if</b></span><span style="color: black;">(pe
!= </span><span style="color: #7f0055;"><b>NULL</b></span><span style="color: black;">
&& pe.SIZE()>0){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> for</b></span><span style="color: black;">(Schema.PicklistEntry
p:pe){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfOpt.add(p.getLabel());</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> return</b></span><span style="color: black;">
listOfOpt;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span>
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
} </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><u><br /></u></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: teal;">@RemoteAction</span>
</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper getOuterWrapperObject(string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #2218e6;"> Opportunity</span><span style="color: black;">
opp = [</span><span style="color: #7f0055;"><b>Select</b></span><span style="color: black;">
o.</span><span style="color: #2218e6;">Name</span><span style="color: black;">,
o.Id, o.Description </span><span style="color: #7f0055;"><b>From</b></span><span style="color: black;">
</span><span style="color: #2218e6;">Opportunity</span><span style="color: black;">
o </span><span style="color: #7f0055;"><b>WHERE</b></span><span style="color: black;">
Id=:oppId];</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> OuterWrapper
objOuterWrapper = <span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
OuterWrapper(Opp);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black;"><span style="font-family: inherit;"> </span><innerwrapper>List<InnerWrapper> <span style="font-family: inherit;">listOfInnerWrapperT = </span></innerwrapper><span style="color: #7f0055; font-family: inherit;"><b>new</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><innerwrapper>List<InnerWrapper><span style="font-family: inherit;">();</span></innerwrapper></span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfInnerWrapperT.add(<span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
InnerWrapper(</span><span style="color: green;">'TEST1'</span><span style="color: black;">,</span><span style="color: green;">'DESC1'</span><span style="color: black;">));</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> objOuterWrapper.listOfInnerWrapper
= listOfInnerWrapperT;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> return</b></span><span style="color: black;">
objOuterWrapper;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: teal;">@RemoteAction</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;">
</span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>static</b></span><span style="color: black;">
OuterWrapper setOuterWrapperObject(String jsonString, string oppId){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> OuterWrapper
objOuterWrapper = </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> (OuterWrapper)System.JSON.deserialize(jsonString,OuterWrapper.Class);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #2218e6;"> Opportunity</span><span style="color: black;">
opp = </span><span style="color: #7f0055;"><b>new</b></span><span style="color: black;">
</span><span style="color: #2218e6;">Opportunity</span><span style="color: black;">(Id=oppId);</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> opp.Description
= objOuterWrapper.oppDescription;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> update</b></span><span style="color: black;">
opp;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> return</b></span><span style="color: black;">
objOuterWrapper;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;">
}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> </span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>class</b></span><span style="color: black;">
InnerWrapper{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
string name {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
string description {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black;"><span style="color: #7f0055; font-family: inherit;"><b><br /></b></span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
InnerWrapper(String strName, String strDesceription){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> this</b></span><span style="color: black;">.name
= strName;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"><span style="color: #7f0055;"><b> this</b></span><span style="color: black;">.description
= strDesceription;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> </span><span style="color: #7f0055;"><b>global</b></span><span style="color: black;">
</span><span style="color: #7f0055;"><b>class</b></span><span style="color: black;">
OuterWrapper{</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
String oppName {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
String oppDescription {get;</span><span style="color: #7f0055;"><b>set</b></span><span style="color: black;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black;"><span style="color: #7f0055; font-family: inherit;"><b> public</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><innerwrapper>List<InnerWrapper> <span style="font-family: inherit;">listOfInnerWrapper {get;</span></innerwrapper></span><span style="color: #7f0055; font-family: inherit;"><b>set</b></span><span style="color: black; font-family: inherit;">;}</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"></span><span style="color: #7f0055; font-family: inherit;"><b> public</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><string>List<String> <span style="font-family: inherit;">listOfStr_SelectOptions {get;</span></string></span><span style="color: #7f0055; font-family: inherit;"><b>set</b></span><span style="color: black; font-family: inherit;">;}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"></span><span style="color: #7f0055;"><b> public</b></span><span style="color: black;">
OuterWrapper(</span><span style="color: #2218e6;">Opportunity</span><span style="color: black;">
o){</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfStr_SelectOptions
= SelectOptions_Global;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> listOfInnerWrapper
= </span><span style="color: #7f0055; font-family: inherit;"><b>new</b></span><span style="color: black;"><span style="font-family: inherit;"> </span><innerwrapper>List<InnerWrapper><span style="font-family: inherit;">();</span></innerwrapper></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span style="color: black;"> oppName
= o.</span><span style="color: #2218e6;">Name</span><span style="color: black;">;</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> oppDescription
= o.Description;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="color: black; font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">VF
Page</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
</div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><apex:page controller="JSremotingController" sidebar="false" showHeader="false"></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <apex:form id="form1"></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <apex:includescript value="{!URLFOR($Resource.JS,'jquery-1.4.2.min.js')}" /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <apex:includescript value="{!URLFOR($Resource.JS,'mustache.js')}" /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <script type="text/javascript"></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> var result_Global;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> var Opp_Id = '006900000071POn';</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> function getOuterWrapperObjectByJSRemoting(oppId) {</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> JSremotingController.getOuterWrapperObject(oppId, function(result, event){</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> if (event.status) {</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> result_Global= result;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> var template = "<b><span>Opportunity Name:</span> {{oppName}}</b><br/><br/><span>Opportunity Description</span> {{oppDescription}}";</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> var html = Mustache.to_html(template, result);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> $('#SPANOppName').html(html);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> } else if (event.type === 'exception') { </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> alert("exception");</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> document.getElementById("responseErrors").innerHTML = event.message;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> } else {</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> alert("else");</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> document.getElementById("responseErrors").innerHTML = event.message;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}, {escape:true});</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">$(document).ready(function(){</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> getOuterWrapperObjectByJSRemoting(Opp_Id);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">});</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">var result_Global2;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> function SetOuterWrapperObjectByJSRemoting(jsonString, oppId){</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> JSremotingController.setOuterWrapperObject(jsonString, oppId, function(result, event){</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> if(event.status) {</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>result_Global2 = result;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> alert('updated..!!');</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> } else if (event.type === 'exception') {</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> alert("exception");</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> document.getElementById("responseErrors").innerHTML = event.message;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> } else {</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> alert("else");</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> document.getElementById("responseErrors").innerHTML = event.message;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> }</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> }, {escape:true});</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">}</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">var JSON_STR;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">function getJSONObject(){</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> //Outer Wrapper</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> var objOpportunityWrapper = new Object();</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> objOpportunityWrapper["oppDescription"] = $("#inputOppDescription").val();</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> var InnerWrapper = new Object();</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> var InnerWrapperArray = new Array();</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> InnerWrapper["name"] = 'TEST Name1';</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> InnerWrapper["description"] = 'TEST Description1';</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> InnerWrapperArray[0] = InnerWrapper;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> objOpportunityWrapper["listOfInnerWrapper"] = InnerWrapperArray;</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> JSON_STR = JSON.stringify(objOpportunityWrapper);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> SetOuterWrapperObjectByJSRemoting(JSON_STR,Opp_Id);</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">} </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"></script> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <apex:pageBlock title="GET DATA BY JS REMOTING"></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <apex:pageBlockSection ></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <span class="Apple-tab-span" style="white-space: pre;"> </span><span id="SPANOppName"></span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </apex:pageBlockSection></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> </apex:pageBlock><span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <apex:pageBlock title="SET/UPDATE DATA BY JS REMOTING"></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span><apex:pageBlockSection ></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <span class="Apple-tab-span" style="white-space: pre;"> </span><apex:pageBlockSectionItem ><span class="Apple-tab-span" style="white-space: pre;"> </span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <span class="Apple-tab-span" style="white-space: pre;"> </span><span>Opportunity Description</span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <span class="Apple-tab-span" style="white-space: pre;"> </span><input type="text" id="inputOppDescription" /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> <span class="Apple-tab-span" style="white-space: pre;"> </span></apex:pageBlockSectionItem></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span><apex:pageBlockSectionItem ><span class="Apple-tab-span" style="white-space: pre;"> </span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span><input type="button" onclick="getJSONObject()" value="Update" <span class="Apple-tab-span" style="white-space: pre;"> </span>class="btn"/></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span></apex:pageBlockSectionItem><span class="Apple-tab-span" style="white-space: pre;"> </span></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><span class="Apple-tab-span" style="white-space: pre;"> </span> </apex:pageBlockSection></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> </apex:pageBlock></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> </apex:form><span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"></apex:page></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;">to run this example you just need to copy & paste & change the Opp id in in the top of the vf page.</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"> var Opp_Id = '006900000071POn';</span></div>
<div align="LEFT" lang="en-US" style="margin-bottom: 0in;">
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;">the page ui will be as below</span></div>
<span style="font-family: inherit;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaCMcKSoERL93isi0m8Mu7FdgsMk7IWTdNMLaFhwmDTVQUPH9RljxRhyphenhyphenBA1bfFJUHYU6azEKJbKCYFpXLVVtpu-LkXOW-yOsmVPU1jozNGIX0TN0f-ejIudhHwW4jDZMyD6OKm3gi2BUY/s1600/UI.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span style="font-family: inherit;"><img border="0" height="59" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaCMcKSoERL93isi0m8Mu7FdgsMk7IWTdNMLaFhwmDTVQUPH9RljxRhyphenhyphenBA1bfFJUHYU6azEKJbKCYFpXLVVtpu-LkXOW-yOsmVPU1jozNGIX0TN0f-ejIudhHwW4jDZMyD6OKm3gi2BUY/s320/UI.png" width="320" /></span></a></div>
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<span style="font-family: inherit;"><br /></span><br />
<br /></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com1tag:blogger.com,1999:blog-5414661301757453099.post-5460697671147018872012-02-21T00:54:00.003-08:002012-02-21T01:04:19.525-08:00IE double click on List Select Option<div dir="ltr" style="text-align: left;" trbidi="on"><br />
I recently came across a very strange issue in IE. The requirement was adding a action on select option double click of a list. The double click is working fine for all other controls in IE but was not working in case of select option.<br />
In Mozilla & Chrome below code working as expected --<br />
<br />
$("#list1").find("option").unbind('dblclick');<br />
$("#list1").find('option').dblclick(function(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//put your code here whatever needed on double click<br />
});<br />
<br />
but IE not able to get the double click on select option & not performing the action as other browsers. I did some Rnd on the issue but haven;t got any solution, even in some post mentioned that this is not supported on IE.<br />
I am thankful to my friend Kapil Choudhary who help me to fix this issue. Here is the script for IE which will work on all browsers perfectly.<br />
<br />
$("#list1").unbind('dblclick');<br />
$("#list1").dblclick(function () {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$("#list1").find('option:selected').each(function() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//put your code here whatever needed on double click<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>});<br />
});<br />
<div><br />
</div></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-41941105524680180532012-01-21T02:10:00.000-08:002012-01-22T07:11:53.144-08:00Use Apply With Linked In Salesforce Site<div dir="ltr" style="text-align: left;" trbidi="on"><br />
I am back after couple of months. Recently I started to look into the Linked in Salesforce integration. I found this very interesting & keep diging & finally implemented as web site page which is using apply with linked-on button. Here are the complete steps by which you can add “Apply with Linked In” button to your VF site.<br />
1-go this below url & create a developer login on linked in-<br />
<a href="https://www.linkedin.com/reg/join">https://www.linkedin.com/reg/join</a><br />
2-Login with the linked-in password by below url<br />
<a href="http://developer.linkedin.com/user/login">http://developer.linkedin.com/user/login</a><br />
2-go to below url & click on “Create On API Key” link<br />
<a href="https://developer.linkedin.com/apply-getting-started">https://developer.linkedin.com/apply-getting-started</a><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj49HRIFCTGdRyVbdiBZqLDwhbgnTK9srTodMVicGLZWogZL5ATkRa2Y4-SwxBd-ixDQ8Q5GZXdnEvtWcWdVer-RBQ1cMWMvBP949TOnM-Zfis8X0bgaKACISOypk3eDZYUbyraNsXl_tY/s1600/CreateAPIKey-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="113" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj49HRIFCTGdRyVbdiBZqLDwhbgnTK9srTodMVicGLZWogZL5ATkRa2Y4-SwxBd-ixDQ8Q5GZXdnEvtWcWdVer-RBQ1cMWMvBP949TOnM-Zfis8X0bgaKACISOypk3eDZYUbyraNsXl_tY/s320/CreateAPIKey-1.png" width="320" /></a></div><br />
3-You will see a page as below.<br />
<div class="separator" style="clear: both; text-align: center;"></div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIKdMWTlmMkX7VOkCC5K1GHE92Z-04f1szF75LwUjNgKch5Teb4uulV2GK_25NREpwvmFAzdOT59sDk1Lh6fmfns9-dLGNVcoiRm_80GaImKNuJxBSAFgBuh_XaAEhOlcRq8LzNUYSCQc/s1600/CreateAPIKey-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="133" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIKdMWTlmMkX7VOkCC5K1GHE92Z-04f1szF75LwUjNgKch5Teb4uulV2GK_25NREpwvmFAzdOT59sDk1Lh6fmfns9-dLGNVcoiRm_80GaImKNuJxBSAFgBuh_XaAEhOlcRq8LzNUYSCQc/s320/CreateAPIKey-2.png" width="320" /></a></div><br />
</div><div><br />
</div><div><div>Click on “Add New Application” Link, fill all the values in the next form & in the “JavaScript API Domain:” text box enter your site url. For Eg In my case it was “http://kgblog-developer-edition.ap1.force.com/apex/ApplyWithLinkedIn”</div><div>Click on save & you will see some information on the page, something like api key, secret key etc. do not close this window, it will be used in next step.</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXaflDn6eGQPW8WoJO1RjGGAVOKm7DypxKk4hMKU5eizf_f-Zlq8tThQWFKbeCo4Hsk54ckTJvOBU5Fvh0DNYzyHtC9AxEKtLr7YnZcsfGpYFQIEb9tyx3bRaSpqlZyl2l4jp6eSFthbM/s1600/CreateAPIKey-3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="104" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXaflDn6eGQPW8WoJO1RjGGAVOKm7DypxKk4hMKU5eizf_f-Zlq8tThQWFKbeCo4Hsk54ckTJvOBU5Fvh0DNYzyHtC9AxEKtLr7YnZcsfGpYFQIEb9tyx3bRaSpqlZyl2l4jp6eSFthbM/s320/CreateAPIKey-3.png" width="320" /></a></div><div><br />
</div><div><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIhYb_pw8QK7aHNLG2vhdBB1NXHEBw_X5dijLTg2QLueSlWwwtw0Rs0VXNAE8H3C_GZbpyPxt69e0X3EhuUNXCOQE_CyGUZhi9RxTi09lGUiZNAwYE_HyrcrCwmm5juRLr7QCqXHg2cSY/s1600/CreateAPIKey-4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="194" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIhYb_pw8QK7aHNLG2vhdBB1NXHEBw_X5dijLTg2QLueSlWwwtw0Rs0VXNAE8H3C_GZbpyPxt69e0X3EhuUNXCOQE_CyGUZhi9RxTi09lGUiZNAwYE_HyrcrCwmm5juRLr7QCqXHg2cSY/s320/CreateAPIKey-4.png" width="320" /></a></div><div><br />
</div><div><br />
</div><div>4-Now go to below url </div><div><a href="https://developer.linkedin.com/plugins/apply">https://developer.linkedin.com/plugins/apply</a> & click on Get Code button. You will see something link as below-</div><div><script src="http://platform.linkedin.com/in.js" type="text/javascript"></div><div> api_key: YOUR_API_KEY</div><div></script></div><div><script type="IN/Apply" data-companyid="XXXX" data-jobtitle="test" data-email="XXXXX@yahoo.com"></script></div><div>Copy this js code & put it in your vf page. </div><div>Replace api key in above code which we get step-3.</div><div>5-now run the site page, you will see apply with linked button on your page.</div><div>If you are building an application in which you need some input something like name, email & some other information from the linked site than you can use “apply with linked in” button .<br />
<br />
<script type="IN/Apply" data-companyid="XXXX" data-jobtitle="Manager" data-joblocation="Delhi" data-callback="onCallBack" ></script><br />
& the js method will be as below<br />
<br />
<script>
</p><p>
<span class="Apple-tab-span" style="white-space:pre"> </span>var success ; </p><p>
function onCallBack(r,e) {</p><p>
success = r; </p><p>
document.getElementById("txt1").value = r.person.firstName; </p><p>
document.getElementById("txt2").value = r.person.lastName;</p><p>
document.getElementById("txt3").value = r.person.emailAddress;</p><p>
document.getElementById("txt4").value = r.person.publicProfileUrl;</p><p>
</p><p>
}</p><p>
</p><p>
<span class="Apple-tab-span" style="white-space:pre"> </span>
</script><br />
<br />
<script><br />
<span style="white-space: pre;"><br />
</span><br />
function onCallBack(p1,p2) {<br />
document.getElementById("txt1").value = p1.person.firstName;<br />
document.getElementById("txt2").value = p1.person.lastName;<br />
document.getElementById("txt3").value = p1.person.emailAddress;<br />
document.getElementById("txt4").value = p1.person.publicProfileUrl;<br />
<br />
}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></script><br />
<br />
<br />
take a look of the demo by below url</div><div><a href="http://kgblog-developer-edition.ap1.force.com/apex/ApplyWithLinkedIn">http://kgblog-developer-edition.ap1.force.com/apex/ApplyWithLinkedIn</a></div></div><div><br />
</div></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com2tag:blogger.com,1999:blog-5414661301757453099.post-75522882359658401432011-03-11T08:41:00.000-08:002013-05-14T00:15:07.839-07:00Play with bulk data - Apex Batch Class<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
Wherever you want to perform some operation on bulk data the Batch Class is the right option for that.</div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
Here I am going to explain t<span style="font-size: small;">he steps of ho</span>w a batch class can be implemented….</div>
<div style="font-family: Georgia,"Times New Roman",serif;">
</div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; text-align: left; text-indent: 18pt;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; text-align: left; text-indent: 18pt;">
declare a batch class</div>
<div class="MsoNormal" style="text-indent: 18pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">global class </span></b><span style="font-family: 'Courier New'; line-height: 115%;">TestBatchClass<b><span style="color: #7f0055;"> implements </span></b>Database.Batchable </span><span style="font-family: 'Courier New'; line-height: 115%;"><span style="font-family: Georgia, 'Times New Roman', serif;"><</span><span style="font-family: Georgia, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-family: 'Courier New';">Sobject</span>></span><sobject><sobject>,Database.Stateful{</sobject></sobject></span></span></div>
<div class="MsoNormal" style="margin-left: 18pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;"> public </span></b><span style="font-family: 'Courier New'; line-height: 115%;">Id accountId<b><span style="color: #7f0055;">{get;set;}</span></b></span></span></div>
<div class="MsoNormal" style="margin-left: 18pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">}</span></b></span></div>
<div class="MsoNormal" style="margin-left: 18pt;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; margin-left: 18pt;">
<span style="font-size: small;"><span style="line-height: 115%;">The syntex will be same for all batch classes you only need to change the class name “TestBatchClass”. </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; margin-left: 18pt;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; margin-left: 18pt;">
<span style="font-size: small;"><span style="line-height: 115%;">Here I am taking an example of account updation, suppose we want to perform some operation on accounts than we need to take a property accountId in the batch class. This property will be used when we create test class for this batch class.</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; margin-left: 18pt;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; margin-left: 18pt;">
</div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; text-indent: 18pt;">
<span style="font-size: small;"><span style="line-height: 115%;">In below lines I am declaring constructor for the batch class</span></span></div>
<div class="MsoNormal" style="text-indent: 18pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">public</span></b><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> </span><span style="font-family: 'Courier New'; line-height: 115%;">TestBatchClass<span style="color: black;">(){</span></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-indent: 18pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';">}</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-indent: 18pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New';">public</span></b><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">TestBatchClass<b><span style="color: #7f0055;"> </span></b><span style="color: black;">(Id accountId){</span></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">this</span></b><span style="color: black; font-family: 'Courier New';">.accountId = accountId;</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> }</span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> <span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif;"> One noticeable point is second constructor will be used when we write test </span></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> class for this batch class. You can avoid the parameterize constructor if does not </span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif; line-height: 115%;"> required in your case.</span></span><span style="color: black; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span></div>
<div class="MsoNormal" style="margin-left: 18pt;">
<br /></div>
<div class="MsoNormal" style="margin-left: 18pt;">
</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="color: olive; font-family: 'Courier New'; font-size: 9pt;"> <span style="font-size: small;"> </span><span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif;">//--------------------------------------------------------------//</span></span></span><span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif;"></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black;"> </span><span style="color: olive;"> //Start Method :-></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: olive;"> //-------------------------------------------------------------//</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black;"> </span><b><span style="color: #7f0055;"> global</span></b><span style="color: black;"> Database.Querylocator start(Database.BatchableContext ctx){</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black;"> return null;</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> }</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: x-small;"><span style="line-height: 115%;"> </span><span style="font-size: small; line-height: 115%;">As per the name start method will be called as the class start execution. In this method </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> you need to change the query as per you requirement. For Eg we are using a query to get </span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif; line-height: 115%;"> accounts on which we will perform some operations.</span></span><span style="font-family: 'Courier New'; font-size: small; line-height: 115%;"> </span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span></div>
<div class="MsoNormal">
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> <span style="font-size: small;"> </span></span> </div>
<div class="MsoNormal">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;"> <span style="font-family: Georgia, 'Times New Roman', serif;">if</span></span></b></span><span style="font-size: small;"><span style="color: black; font-family: Georgia, 'Times New Roman', serif; line-height: 115%;">(test.isrunningTest()) {</span><span style="font-family: Georgia, 'Times New Roman', serif; line-height: 115%;"></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> </span><b><span style="color: #7f0055; line-height: 115%;">return</span></b><span style="color: black; line-height: 115%;"> Database.getQueryLocator([</span><span style="line-height: 115%;"></span><b><span style="color: #7f0055;">select</span></b><span style="color: black;"> Id,</span><span style="color: #2218e6;">Name </span><b><span style="color: #7f0055;">from</span></b><span style="color: black;"> </span><span style="color: #2218e6;">Account</span><span style="color: black;"> </span><b><span style="color: #7f0055;"></span></b><span style="color: black;">limit 5]);</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black;"> }</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><b><span style="color: #7f0055;"> else</span></b><span style="color: black;">{</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black;"> </span><b><span style="color: #7f0055;">return</span></b><span style="color: black;"> Database.getQueryLocator([</span><b><span style="color: #7f0055;">select</span></b><span style="color: black;"> Id,</span><span style="color: #2218e6;">Name</span><span style="color: black;"> </span><b><span style="color: #7f0055;">from</span></b><span style="color: black;"> </span><span style="color: #2218e6;">Account</span><span style="color: black;"> </span><b><span style="color: #7f0055;">where</span></b><span style="color: black;"> Id=: accountId]); </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"> <span style="color: black; line-height: 115%;">}</span> </span></div>
<span style="font-size: small;"> </span><br />
<span style="font-family: Georgia, 'Times New Roman', serif; font-size: small;"> <span style="line-height: 115%;">Here one noticeable point is there are two queries to get the accounts. Test.isrunninTest </span></span><br />
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> checks and execute the first query if we are calling this batch class from test class, it </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> will useful because we should not perform the batch logic for thousands of account if it is </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> calling from Test class.</span></span></div>
<br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span> <br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="color: olive; font-family: 'Courier New'; font-size: 9pt;"> <span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif;"> //--------------------------------------------------------------//</span></span></span><span style="font-size: small;"><span style="font-family: Georgia, 'Times New Roman', serif;"></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: olive;"> //Execute method</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: olive;"> //-------------------------------------------------------------//</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><b><span style="color: #7f0055; line-height: 115%;"> global</span></b><span style="color: black; line-height: 115%;"> </span><b><span style="color: #7f0055; line-height: 115%;">void</span></b><span style="color: black; line-height: 115%;"> execute(Database.BatchableContext ctx, <span class="Apple-style-span" style="font-family: 'Courier New';"><span style="font-family: Georgia, 'Times New Roman', serif;">List<</span><span style="color: #2218e6; font-family: Georgia, 'Times New Roman', serif;">Account</span><span style="font-family: Georgia, 'Times New Roman', serif;">></span></span><account><sobject>){</sobject></account></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"> <span style="color: black; line-height: 115%;">} </span></span></div>
<br />
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> </span><span style="line-height: 115%;">Execute method is the most important method of the batch class, here you need to write the </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> logic on the basis of you want to perform update/insert/delete operation. For Eg if we need </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> to change a field the fetched accounts than the code will be look like as below-</span></span></div>
<br />
<br />
<div class="MsoNormal">
<span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;"> <span style="font-family: Georgia, 'Times New Roman', serif;">List<</span><span style="color: #2218e6; font-family: Georgia, 'Times New Roman', serif;">Account</span><span style="font-family: Georgia, 'Times New Roman', serif;">> listOfAccounts = (List<</span><span style="color: #2218e6; font-family: Georgia, 'Times New Roman', serif;">Account</span><span style="font-family: Georgia, 'Times New Roman', serif;">>)scope; </span></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> List<<span style="color: #2218e6;">Account</span>> listOfAccountsUpdated = <b><span style="color: #7f0055;">new</span></b> List<<span style="color: #2218e6;">Account</span>>(); </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: #2218e6; line-height: 115%;"> Account</span><span style="line-height: 115%;"> newAccount;</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><b><span style="color: #7f0055; line-height: 115%;"> for</span></b><b><span style="line-height: 115%;">(Account</span></b><span style="line-height: 115%;"> acct :listOfAccounts) {</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt; text-indent: 36pt;">
<span style="font-size: small;">newAccount = new <span style="color: #2218e6;">Account</span>(Id = acct.Id);</span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"> newAccount.checked__c = true;</span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif; line-height: normal; margin-bottom: 0.0001pt; text-indent: 36pt;">
<span style="font-size: small;">listOfAccountsUpdated.add(newAccount);</span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> }</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><b><span style="color: #7f0055; line-height: 115%;"> If</span></b><span style="line-height: 115%;">(listOfAccountsUpdated.Size()>0){</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> Update listOfAccountsUpdated;</span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"> <span style="line-height: 115%;">}</span></span></div>
<br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span><br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> <span style="font-family: Georgia, 'Times New Roman', serif; font-size: small;"> </span></span><span style="font-family: Georgia, 'Times New Roman', serif; font-size: small;"><span style="line-height: 115%;">At the end of the batch class there is finish method, generally you need not to write any </span></span><br />
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> code in this method, you can write some code if there is any specific requirement at the </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> end of batch execution. for eg. send a mail in finish.</span></span></div>
<br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span> <br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="color: olive; font-family: 'Courier New'; font-size: 9pt;"> <span style="font-size: small;">//--------------------------------------------------------//</span></span><span style="font-size: small;"><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: olive; font-family: 'Courier New';"> //Finish method</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: olive; font-family: 'Courier New';"> //----------------------------------------------------------//</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New';"> global</span></b><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">void</span></b><span style="color: black; font-family: 'Courier New';"> finish(Database.BatchableContext ctx){</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> }</span></span><br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> <span style="font-size: small;">The whole class code will be look like as below-</span></span></div>
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span><br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span><br />
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span></b><br />
<b><span style="color: #7f0055; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"><span style="font-size: small;"> global class </span></span></b><span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;">TestBatchClass</span></span><span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;"><b><span style="color: #7f0055;"> implements </span></b></span></span><span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;">Database.Batchable </span></span><span class="Apple-style-span" style="font-family: 'Courier New'; line-height: 18px;"><span style="font-family: Georgia, 'Times New Roman', serif;"><</span><span style="font-family: Georgia, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-family: 'Courier New';">Sobject</span>>,</span></span><span class="Apple-style-span" style="font-family: 'Courier New'; line-height: 18px;"> Database.Stateful<b><span style="color: #7f0055;"> {</span></b></span><br />
<div class="MsoNormal">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;"> public </span></b><b><span style="font-family: 'Courier New'; line-height: 115%;">Id<span style="color: #7f0055;"> </span></span></b><span style="color: black; font-family: 'Courier New'; line-height: 115%;">accountId{get;set;} </span><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;"> </span></b></span></div>
<div class="MsoNormal">
<span style="font-size: small;"> <b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">public</span></b><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> </span><span style="font-family: 'Courier New'; line-height: 115%;">TestBatchClass<span style="color: black;">(){</span></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> }</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">public</span></b><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';">TestBatchClass<b><span style="color: #7f0055;"> </span></b><span style="color: black;">(Id accountId){</span></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">this</span></b><span style="color: black; font-family: 'Courier New';">.accountId = accountId;</span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> }</span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="color: olive; font-family: 'Courier New'; font-size: 9pt;"> <span style="font-size: small;">//--------------------------------------------------------//</span></span><span style="font-size: small;"><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//Start Method :-></span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//----------------------------------------------------------//</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">global</span></b><span style="color: black; font-family: 'Courier New';"> Database.Querylocator start(Database.BatchableContext ctx){</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">if</span></b><span style="color: black; font-family: 'Courier New';">(test.isrunningTest()) {</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">return</span></b><span style="color: black; font-family: 'Courier New';"> Database.getQueryLocator([</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 72pt; text-indent: 36pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New';">select</span></b><span style="color: black; font-family: 'Courier New';"> Id,</span><span style="color: #2218e6; font-family: 'Courier New';">Name </span><b><span style="color: #7f0055; font-family: 'Courier New';">from</span></b><span style="color: black; font-family: 'Courier New';"> </span><span style="color: #2218e6; font-family: 'Courier New';">Account</span><span style="color: black; font-family: 'Courier New';"> limit 5]);</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> }</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">else</span></b><span style="color: black; font-family: 'Courier New';">{</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">return</span></b><span style="color: black; font-family: 'Courier New';"> Database.getQueryLocator([</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 72pt; text-indent: 36pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New';">select</span></b><span style="color: black; font-family: 'Courier New';"> Id,</span><span style="color: #2218e6; font-family: 'Courier New';">Name</span><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">from</span></b><span style="color: black; font-family: 'Courier New';"> </span><span style="color: #2218e6; font-family: 'Courier New';">Account</span><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">where</span></b><span style="color: black; font-family: 'Courier New';"> Id=: accountId]); </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> } </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> } </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//--------------------------------------------------------//</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//Execute method</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//---------------------------------------------------------//</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">global</span></b><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> </span><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">void</span></b><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> execute(Database.BatchableContext ctx, <span style="font-family: Georgia, 'Times New Roman', serif;">List<</span><span style="color: #2218e6; font-family: Georgia, 'Times New Roman', serif;">Account</span><span style="font-family: Georgia, 'Times New Roman', serif;">> </span><sobject>scope){</sobject></span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> </span><span style="font-family: 'Courier New'; line-height: 115%;">List<<span style="color: #2218e6;">Account</span>> listOfAccounts = (List<<span style="color: #2218e6;">Account</span>>)scope; </span></span></div>
<div class="MsoNormal" style="text-indent: 36pt;">
<span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;">List<<span style="color: #2218e6;">Account</span>> listOfAccountsUpdated = <b><span style="color: #7f0055;">new</span></b> List<<span style="color: #2218e6;">Account</span>>(); </span></span></div>
<div class="MsoNormal" style="text-indent: 36pt;">
<span style="font-size: small;"><span style="color: #2218e6; font-family: 'Courier New'; line-height: 115%;">Account</span><span style="font-family: 'Courier New'; line-height: 115%;"> newAccount;</span></span></div>
<div class="MsoNormal" style="text-indent: 36pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">for</span></b><b><span style="font-family: 'Courier New'; line-height: 115%;">(Account</span></b><span style="font-family: 'Courier New'; line-height: 115%;"> acct :listOfAccounts) {</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 36pt; text-indent: 36pt;">
<span style="font-size: small;"><span style="font-family: 'Courier New';">newAccount = new <span style="color: #2218e6;">Account</span>(Id = acct.Id);</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="font-family: 'Courier New';"> newAccount.checked__c = true;</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0cm 0cm 0.0001pt 36pt; text-indent: 36pt;">
<span style="font-size: small;"><span style="font-family: 'Courier New';">listOfAccountsUpdated.add(newAccount);</span></span></div>
<div class="MsoNormal" style="text-indent: 36pt;">
<span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;">}</span></span></div>
<div class="MsoNormal" style="text-indent: 36pt;">
<span style="font-size: small;"><b><span style="color: #7f0055; font-family: 'Courier New'; line-height: 115%;">If</span></b><span style="font-family: 'Courier New'; line-height: 115%;">(listOfAccountsUpdated.Size()>0){</span></span></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;"> Update listOfAccountsUpdated;</span></span></div>
<div class="MsoNormal" style="text-indent: 36pt;">
<span style="font-size: small;"><span style="font-family: 'Courier New'; line-height: 115%;">}</span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> } </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: olive; font-family: 'Courier New';"> //-------------------------------------------------------//</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//Finish method</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="color: olive; font-family: 'Courier New';">//--------------------------------------------------------//</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">global</span></b><span style="color: black; font-family: 'Courier New';"> </span><b><span style="color: #7f0055; font-family: 'Courier New';">void</span></b><span style="color: black; font-family: 'Courier New';"> finish(Database.BatchableContext ctx){</span><span style="font-family: 'Courier New';"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt;">
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New';"> </span><span style="font-family: 'Courier New';"></span></span></div>
<span style="font-size: small;"><span style="color: black; font-family: 'Courier New'; line-height: 115%;"> }</span></span><br />
<span style="color: black; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> } </span><br />
<span style="color: black; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"><br />
</span><br />
<br />
<div class="MsoNormal">
<span style="color: black; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> <span style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">it's done..!!</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"><br />
</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> If you want to test this batch class then open the system log & execute below lines of </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> code </span><span style="color: black; line-height: 115%;"></span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
</div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="line-height: 115%;"> TestBatchClass<b><span style="color: #7f0055;"> </span></b><span style="color: black;">obj = new </span>TestBatchClass<b><span style="color: #7f0055;"> </span></b><span style="color: black;">();</span></span></span></div>
<span style="font-family: Georgia, 'Times New Roman', serif; font-size: small;"> <span style="color: black; line-height: 115%;">Database.executeBatch(obj,5);</span></span><br />
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
</div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> In execute batch you can specify how many records need to take in a batch, for example we </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> are taking 5. Generally we should not take more than 200 for this.</span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<br /></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> Now you can check the implementation flow/bugs in the system log detail & manipulate the </span></span></div>
<div class="MsoNormal" style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> logic of the batch class.</span></span></div>
<br />
<span style="color: black; font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"><span style="font-family: Georgia, 'Times New Roman', serif; font-size: small;">After executing this batch class sometimes you will not able to save data in the class if </span></span><br />
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> there any error thrown in by batch class & batch class not execute successfully. For this </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> you need to go to Setup->Monitoring->Apex Jobs & then Abort the job. In our case it will be </span></span></div>
<div style="font-family: Georgia,"Times New Roman",serif;">
<span style="font-size: small;"><span style="color: black; line-height: 115%;"> “</span><span style="line-height: 115%;">TestBatchClass”. </span></span></div>
<div class="MsoNormal">
<br /></div>
<span style="font-family: 'Courier New'; font-size: 9pt; line-height: 115%;"> </span><br />
Happy Coding...!!<br />
<b><u><span style="font-family: Calibri, sans-serif; font-size: 11pt; line-height: 115%;"> </span></u></b></div>
Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com1tag:blogger.com,1999:blog-5414661301757453099.post-73811308888359435872011-01-31T19:04:00.000-08:002011-02-08T19:34:13.097-08:00Access Salesforce Content on your VF Page<div dir="ltr" style="text-align: left;" trbidi="on"><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;">Recently I came across the Salesforce Content Related requirement, Salesforce only provide limited access to the content (ContentVersion object). It does not allow you to access the Content & show in your custom VF page.</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;">Here Me & my friend Vinod did a lot of Rnd & found a easy solution. This post will save your lot of time if you are doing this kind of task with Content.</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;">To implement its example, take a div</span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><div class="centerContent" id="myDiv"></div></span><br />
</div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">There are two simple JS function which will help to get salesforce content – </span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"></span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">function OpenDoc(docId){</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> </span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">var htmlString = '<div id="chatterFileViewerPanel" class="chatterFileViewerPanel"><br/><br/> <embed height="500px" align="middle" width="500px" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.adobe.com/go/getflashplayer" allowfullscreen="true" allowscriptaccess="sameDomain" ' + </span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">'name="renditionLarge" bgcolor="#f3f3f3" quality="high" id="renditionLarge" ' </span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">+'flashvars="shepherd_prefix=/sfc/servlet.shepherd&amp;v='+docId+'&amp;mode=chatterfilepreview&amp;in_tests=false" src="/static/101210/sfc/flex/DocViewer.swf" /> </div> ';</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> document.getElementById('</span><span style="font-size: small;">myDiv</span><span style="font-size: small;">').innerHTML = htmlString;</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> </span><span style="font-size: small; line-height: 115%;">PrepareFlexComponent</span><span style="font-size: small;">(docId);</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">}</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;">function PrepareFlexComponent(docId){</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> insertFlexComponent('/static/102010/sfc/flex/DocViewer', </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> 'shepherd_prefix=/sfc/servlet.shepherd&v='+docId+'&mode=chatterfilepreview&</span><br />
<span style="font-size: small; line-height: 115%;"> amp;in_tests=false','500px', '500px', '#f3f3f3', 'chatterFileViewerPanel', 'renditionLarge', false, </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> { adobeFlashVersionLbl : 'You must enable or download Adobe Flash Player version 9.0.115 or </span><br />
<span style="font-size: small; line-height: 115%;"> later to use this feature.', </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> downloadAdobeLbl : 'Download Adobe Flash Player', downloadAdobeLinkLbl : 'Click the </span><br />
<span style="font-size: small; line-height: 115%;"> link below to download the Adobe Flash Player:' closeDialogLbl : 'Cancel'}); </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> Ninja.Flex.ContentStaticResourcesBase = '/static/102010/sfc';</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;"> Ninja.Flex.ShepherdController = '/sfc/servlet.shepherd';</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;">} </span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small; line-height: 115%;">Put below script as it is in your page</span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script type="text/javascript" src="/static/101210/js/functions.js"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script src="/EXT/ext-3.0.0/ext.js" type="text/javascript"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script src="/jslibrary/1294273133000/main.js" type="text/javascript"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script src="/jslibrary/1289945557000/Chatter.js" type="text/javascript"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script src="/jslibrary/1289346548000/ChatterFiles.js" type="text/javascript"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script src="/jslibrary/labels/1295420058000/en_US.js" type="text/javascript"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"><script type="text/javascript" src="/static/101210/desktop/desktopAjax.js"></script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black; font-size: small;"><script type="text/javascript" src="/static/101210/sfc/javascript/lib/AC_OETags.js"></script></span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: teal; font-size: small;"><script></span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> postSubDocument(url, internal) {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">var</span></b></span><span style="color: black; font-size: small;"> form = document.getElementById(</span><span style="color: #2a00ff; font-size: small;">"formSubDocument"</span><span style="color: black; font-size: small;">);</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> form.action = url;</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> form.internal.value = internal;</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> form.submit();</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt; text-align: left;"><span style="color: black; font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> hideFlex() {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> document.getElementById(</span><span style="color: #2a00ff; font-size: small;">'IE6Confirm'</span><span style="color: black; font-size: small;">).style.display = </span><span style="color: #2a00ff; font-size: small;">"block"</span><span style="color: black; font-size: small;">;</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> showFlex() {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> document.getElementById(</span><span style="color: #2a00ff; font-size: small;">'IE6Confirm'</span><span style="color: black; font-size: small;">).style.display = </span><span style="color: #2a00ff; font-size: small;">"none"</span><span style="color: black; font-size: small;">;</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> cancelDownload(url) {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> showFlex();</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> triggerDownload(url) {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> window.open(url);</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> downloadDocForIE6() {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> showFlex();</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> triggerDownload(_url);</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">function</span></b></span><span style="color: black; font-size: small;"> downloadDoc(url) {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">var</span></b></span><span style="color: black; font-size: small;"> isIE6 = (navigator.userAgent.indexOf(</span><span style="color: #2a00ff; font-size: small;">"MSIE 6"</span><span style="color: black; font-size: small;">) != -1);</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">if</span></b></span><span style="color: black; font-size: small;"> (isIE6) {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"></span><span style="color: #3f7f5f; font-size: small;"></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> _url = url;</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> hideFlex();</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> </span><span style="font-size: small;"><b><span style="color: #7f0055;">else</span></b></span><span style="color: black; font-size: small;"> {</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"></span><span style="color: #3f7f5f; font-size: small;"></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> triggerDownload(url);</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif; line-height: normal; margin-bottom: 0.0001pt;"><span style="color: black; font-size: small;"> }</span></div><span style="font-size: small;"><br style="font-family: "Trebuchet MS",sans-serif;" /></span><br />
<div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="color: black; font-size: small; line-height: 115%;"> </script></span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="color: teal; font-size: small; line-height: 115%;"><span style="color: black;">It’s done! Now call function</span> </span><span style="font-size: small;">OpenDoc </span><span style="font-size: small;">by passing a ContentId & you can see your Content on VF page :)</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">It will show the content same as the salesforce standard way.</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;">Enjoy..!!</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div><div class="MsoNormal" style="font-family: "Trebuchet MS",sans-serif;"><span style="font-size: small;"><br />
</span></div></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com18tag:blogger.com,1999:blog-5414661301757453099.post-72430555235706531292011-01-25T17:54:00.000-08:002011-01-30T19:29:38.433-08:00SFDC Time saver deployement - "ANT"<div dir="ltr" style="text-align: left;" trbidi="on"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3TlGCkbhW_ZXHFeur66Nq8lU-EZH8Sz-dvZTshyphenhyphenRBxiuUETWjsxP9j33afNprqgiqwoa-yfS00k1IuQ3hbT7zuimRjTIDiLjPNPRfnAIV1LXW3W7-SbdvFbbqXTl6xNiu2ACdlwVAoJQ/s1600/cmdPrompt.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"></a><br />
<div class="Standard"><span lang="DE" style="color: black;">Deployment through eclipse always takes too much time to validate & deployment. Deployment through ant script is quite easy & time saver too :)<o:p></o:p></span></div><div class="Standard"><span class="Apple-style-span"><span lang="DE" style="color: black;"><o:p> </o:p></span><span class="Apple-style-span">Here are some steps by which you can easily configure & deploy your SF stuff to an org.</span></span></div><div class="Standard"></div><div class="Standard" style="margin-left: 36pt; text-indent: -18pt;"><span class="Apple-style-span"><span lang="DE" style="color: black;">·<span style="font: 7pt "Times New Roman";"> </span></span><span lang="DE" style="color: black;">You need to have java on your machine, check this by entering command prompt "java -version".<o:p></o:p></span></span></div><div class="Standard" style="margin-left: 36pt; text-indent: -18pt;"><span class="Apple-style-span"><span lang="DE" style="color: black;">·<span style="font: 7pt "Times New Roman";"> </span></span><span lang="DE" style="color: black;">Need to have ant installation on your machine, check this by entering command prompt "ant -version". One other option if you don't want to install ant on your system, for this get ant folder from some other machine which have installed ant & copy the and folder [which have bin,docs etc] to your local hard drive.<o:p></o:p></span></span></div><div class="Standard" style="margin-left: 36pt; text-indent: -18pt;"><span class="Apple-style-span"><span lang="DE" style="color: black;">·<span style="font: 7pt "Times New Roman";"> </span></span><span lang="DE" style="color: black;">Check or add if below environment variable not set on your machine-<o:p></o:p></span></span></div><div class="Standard"><span lang="DE" style="color: black;"> ANT_HOME = E:\ant [ant folder path where content copied]<o:p></o:p></span></div><div class="Standard" style="text-indent: 36pt;"><span lang="DE" style="color: black;">JAVA_HOME = C:\Program Files\Java\jdk1.6.0_06<o:p></o:p></span></div><div class="Standard" style="margin-left: 36pt;"><span lang="DE" style="color: black;">PATH = %ANT_Home%/bin append this at the end of the existing string, append semicolon before & after this if not added<o:p></o:p></span></div><div class="Standard"><span lang="DE" style="color: black;"><o:p> </o:p></span></div><div class="Standard" style="margin-left: 36pt; text-indent: -18pt;"><span class="Apple-style-span"><span lang="DE" style="color: black;">·<span style="font: 7pt "Times New Roman";"> </span></span><span lang="DE" style="color: black;">Now you need three files to deploy the code.</span></span></div><div class="Standard" style="margin-left: 36pt; text-indent: -18pt;"><span class="Apple-style-span"><span lang="DE" style="color: black;"></span><span class="Apple-tab-span" style="white-space: pre;"> </span>Sample/</span></div><div class="Standard" style="margin-left: 36pt; text-indent: -18pt;"><span lang="DE"> </span></div><div class="Standard" style="color: black;"><span lang="DE" style="color: black;"> build.properties<o:p></o:p></span></div><div class="Standard" style="color: black;"><span lang="DE" style="color: black;"> build.xml<o:p></o:p></span></div><div class="Standard" style="color: black;"><span lang="DE" style="color: black;"> package.xml<o:p></o:p></span></div><div class="Standard" style="color: black;"><span lang="DE" style="color: black;"></span></div><div class="Standard"><span lang="DE" style="color: black;">These files can be found in ant sample folder otherwise you can mail me to get these files. <o:p></o:p></span></div><div class="Standard"><span lang="DE" style="color: black;">Copy these files in a folder somewhere on your local hard drive. Let's say here we copy these file in "Sample" folder.<o:p></o:p></span></div><div class="Standard"><span lang="DE" style="color: black;"><o:p> </o:p></span></div><div class="Standard"><span lang="DE" style="color: black;">Now we are taking files & it’s detail one by one.<o:p></o:p></span></div><div class="Standard"><span class="Apple-style-span"><span lang="DE" style="color: black;"><o:p> </o:p></span>build.properties</span></div><div class="Standard"><span lang="DE" style="color: black;"> this file basically contains the user id & pwd of the source/destination org. You can also specify serverurl,resultFilePath or other useful attributes, we will talk about these one by one.<o:p></o:p></span></div><span style="color: black; line-height: 115%;"> Here are some Eg..</span><br />
<div class="Standard" style="color: black;"><span lang="DE" style="color: black;"><span style="color: black; line-height: 115%;"></span></span></div><div class="Standard"><span lang="DE" style="color: black;"> sf.username = XXXX@XXX.com</span></div><div class="Standard"><span lang="DE" style="color: black;"> sf.password = XXXXXXXXXXXXXXXXXXXXXXXXXXXX [pwd with security token]<o:p></o:p></span></div><span style="color: black; line-height: 115%;"> sf.serverurl = <span style="color: black; text-decoration: none;"><a href="https://login.salesforce.com/">https://login.salesforce.com</a></span></span><br />
<div class="Standard" style="color: black;"><span lang="DE" style="color: black;"><span style="color: black; line-height: 115%;"><span style="color: black; line-height: 115%;"><br />
</span></span></span></div><div class="Standard"><span lang="DE"></span></div><div class="Standard" style="color: black; line-height: 115%;"><span lang="DE" style="color: black;">build.xml<o:p></o:p></span></div><div class="Standard" style="color: black; line-height: 115%;"><span lang="DE" style="color: black;"> this file contains the command. The file also uses the attribute defined in the build.properties file.<o:p></o:p></span></div><div class="Standard" style="color: black; line-height: 115%;"><span lang="DE" style="color: black;"> For Eg.<o:p></o:p></span></div><div class="Standard"><span lang="DE"></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <target name="SpecifyAnyNameHere"></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <mkdir dir="retrieveOutput"/></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveOutput" unpackaged= "package.xml"/></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> </target></span></div><div class="Standard" style="line-height: 14px;"></div><div class="Standard"><span lang="DE" style="color: black;">in this a command wrapped in the <target> node. A name is defined for this command (for Eg-here name is SpecifyAnyNameHere).<o:p></o:p></target></span></div><div class="Standard"><span lang="DE" style="color: black;">Second line creating a new folder/directory.<o:p></o:p></span></div><div class="Standard"><span lang="DE" style="color: black;">Third line shows the operation type, like what we are going to do in this command. In this we retrieve the content from the server. This line uses the Id/Pwd & server url defined in the build.properties file. The value can be used directly here, instead of accessing in this way ${sf.username}.<o:p></o:p></span></div><div class="Standard"><span lang="DE" style="color: black;">RetrieveTarget attribute tell about where the content will be downloaded. Here we are using the same folder just we created in second line.<o:p></o:p></span></div><span style="color: black; line-height: 115%;">Unpackaged attribute is fixed, leave this as it is, this will be more clear in next couple of minutes</span><br />
<div class="Standard"></div><div class="Standard" style="color: black; line-height: 115%;"><span lang="DE" style="color: black;">package.xml<o:p></o:p></span></div><div class="Standard"><span lang="DE"><span style="color: black; line-height: 115%;"> </span><span class="Apple-style-span" style="line-height: 115%;">this file contains what we want to retrieve, in this we mention what component type we want to </span><span class="Apple-style-span" style="line-height: 14px;">retrieve </span><span class="Apple-style-span" style="line-height: 115%;">from server.<o:p></o:p></span></span></div><span style="color: black; line-height: 115%;">For eg if we want to retrieve the class "ChangePasswordController" than the file will be look like as below</span><br />
<div class="Standard"></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><?xml version="1.0" encoding="UTF-8"?></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><Package xmlns="http://soap.sforce.com/2006/04/metadata"></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <types></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <members>ChangePasswordController</members></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <name>ApexClass</name></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> </types></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <version>11.0</version></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"></Package></span></div><div class="Standard" style="line-height: 14px;"></div><div class="Standard"><span lang="DE" style="color: black;">in this we only need to change Component type (for Eg. Here we mentioned ApexClass) & name of the </span></div><div class="Standard"><span lang="DE" style="color: black;">component.<o:p></o:p></span></div><span style="color: black; line-height: 115%;">If you want to retrieve download all class file than you can use * as below-</span><br />
<div class="Standard"></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"><?xml version="1.0" encoding="UTF-8"?></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"><Package xmlns="http://soap.sforce.com/2006/04/metadata"></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <types></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <members>*</members></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <name>ApexClass</name></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <members>*</members></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <name>ApexPage</name></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> </types></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <version>11.0</version></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"></Package></span></span></div><div class="Standard"><span class="Apple-style-span" style="line-height: 14px;"></span></div><div class="Standard"><span lang="DE" style="color: black;">you can view all available Component type in "salesforce_migration_guide".<o:p></o:p></span></div><div class="Standard"><span class="Apple-style-span">Now go to command prompt and go to Sample folder.</span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span"></span><span class="Apple-style-span">Type command as below & press enter.</span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="color: #0000ee;"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5566311596872827986" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3TlGCkbhW_ZXHFeur66Nq8lU-EZH8Sz-dvZTshyphenhyphenRBxiuUETWjsxP9j33afNprqgiqwoa-yfS00k1IuQ3hbT7zuimRjTIDiLjPNPRfnAIV1LXW3W7-SbdvFbbqXTl6xNiu2ACdlwVAoJQ/s320/cmdPrompt.png" style="cursor: pointer; float: left; height: 48px; margin: 0px 10px 10px 0px; width: 320px;" /></span></span></div><div><span class="Apple-style-span"><span class="Apple-style-span" style="color: #0000ee;"><br />
</span></span></div><div class="Standard"><span class="Apple-style-span"></span></div><div class="Standard"><span class="Apple-style-span"><span lang="DE" style="color: black;"><br />
</span></span></div><div class="Standard"><span class="Apple-style-span"><span lang="DE" style="color: black;">Wow!, you get the content(s) which specified in packacge.xml in "retrieveOutput" folder, check it out.<o:p></o:p></span></span></div><span class="Apple-style-span"> <div class="Standard"><span lang="DE" style="color: black;"><o:p> </o:p></span>Now if you want to deploy these contents on any destination org than you need to do below changes.</div><div class="Standard"><span lang="DE" style="color: black;">1-Specify login url, id & password in buid.properties file.<o:p></o:p></span></div><span style="color: black; line-height: 115%;">2-add below command in the build.xml file</span></span><br />
<div class="Standard"><span class="Apple-style-span"></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><target name="deployCodeCheckOnly"></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}"</span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span>deployRoot="retrieveOutput" checkOnly="true"/></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> </target></span></div><div class="Standard"></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><span lang="DE" style="color: black;"> here checkOnly attribute can be used to only check deployment status without changing anything to the destination org.<o:p></o:p></span></span></div><span class="Apple-style-span"> <div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;"> You can remove if you want to directly deploy the contents to the destination org.<o:p></o:p></span></div><div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;"><o:p> </o:p></span></div><div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;"> Now below command on command prompt-<o:p></o:p></span></div><div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;"> >> ant deployCodeCheckOnly<o:p></o:p></span></div><div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;"><o:p> </o:p></span></div><div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;"><o:p> </o:p></span>There are few point's which can be used in different scenarios, I am explaining these one by one -</div><div class="Standard" style="line-height: 14px;"></div><div class="Standard"><span lang="DE" style="color: black;">build.properties attributes<o:p></o:p></span></div><div class="Standard">sf.metadataType = ApexClass (it will be used in bulk retrival, bulk retrival mentioned in next few lines)</div><div class="Standard"><span lang="DE" style="color: black;">sf.pkgName = AutoComplete Textbox (if you want to specify retrive the content of a installed package in the source org.)<o:p></o:p></span></div><div class="Standard"><span lang="DE" style="color: black;">sf.resultFilePath = Deploy/test.txt (specify the file path which wil used to store metadata information.)<o:p></o:p></span></div><div class="Standard"><br />
</div><span style="color: black; line-height: 115%;">build.xml Commands</span><div class="Standard"></div><div class="Standard"><span class="Apple-style-span" style="line-height: 14px;"><target name="bulkRetrieveCommand"></span></div><div class="Standard"><span class="Apple-style-span" style="line-height: 14px;"> <mkdir dir="retrieveOutput2"/></span></div><div class="Standard"><span class="Apple-style-span" style="line-height: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span><sf:bulkRetrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" </span></div><div class="Standard"><span class="Apple-style-span" style="line-height: 14px;"> metadataType="${sf.metadataType}" retrieveTarget="retrieveOutput2"/></span></div><div class="Standard"><span class="Apple-style-span" style="line-height: 14px;"> </target></span></div><div class="Standard"></div><div class="Standard" style="line-height: 14px;"><span lang="DE" style="color: black;">In this we are using specified metedataType specified in the build.properties file as above. Let explore bulk retrieval uses in comparison of normal retrieval.<o:p></o:p></span></div><div class="Standard"><span lang="DE"><span class="Apple-style-span"></span></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><target name="retrievePkg"></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <mkdir dir="retrieveOutput3"/></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" retrieveTarget="retrieveOutput3" packageNames="${sf.pkgName}"</span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> /></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"> </target></span></div><div class="Standard" style="line-height: 14px;"><span class="Apple-style-span"><span style="color: black; line-height: 115%;">If we want to retrieve the contents from a installed package than we can use above command. Here I am using name of packageNames attribute & the name of the package is specified in build.properties file.</span></span></div><div class="Standard"></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"><target name="listMetadata"></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <sf:listMetadata username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" metadataType="${sf.metadataType}" resultFilePath=</span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span> "${sf.resultFilePath}"/></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> </target></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <target name="describeMetadata"></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> <sf:describeMetadata username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" resultFilePath=</span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"><span class="Apple-tab-span" style="white-space: pre;"> </span> "${sf.resultFilePath}" /></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"> </target></span></span></div><div class="Standard"><span class="Apple-style-span"><span class="Apple-style-span" style="line-height: 14px;"></span></span></div><div class="MsoNormal"><span class="Apple-style-span"><span lang="DE" style="color: black; line-height: 115%;">These command can be used to access metadata information. Here resultFilePath attribute used to specify the file name where the metadata information will be stored. The file name specified in the build.properties file.</span></span></div></span><br />
<div style="font-family: 'Trebuchet MS',sans-serif;"></div><div style="font-family: 'Trebuchet MS',sans-serif;"></div><div style="font-family: 'Trebuchet MS',sans-serif;"></div></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com1tag:blogger.com,1999:blog-5414661301757453099.post-44251365358838562662011-01-24T18:08:00.000-08:002011-01-30T19:30:49.409-08:00Half Star Rating in jQuery Plug in<div dir="ltr" style="text-align: left;" trbidi="on"><div style="margin-bottom: 0in;">I recently used jQuery Star Rating in a site, in that I faced a issue regarding the half star rating, for Eg. If the rating is 2 than it can be shown easily but if it is 2.5 it is a little bit difficult to show the correct rating on the plug in. Here is the code if you are facing this type of issue-</div><div style="margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS',sans-serif; font-size: small;">Here is the VF page code & apex class code. In this the calculate method is most important to show the half star rating.</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS',sans-serif; font-size: small;">Apex Class</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS',sans-serif; font-size: small;">===============================================</span></div><div style="margin-bottom: 0in;"></div><div style="margin-bottom: 0in;"><span class="Apple-style-span">public with sharing class StarRatingController {</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> public decimal selctedAverage{get;set;}</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> public decimal averageStar{get;set;}</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> public List<selectoption> getSkillOptionsStar() {</selectoption></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> List<selectoption> skillOptions = new List<selectoption>(); <span class="Apple-tab-span" style="white-space: pre;"> </span></selectoption></selectoption></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> <span class="Apple-tab-span" style="white-space: pre;"> </span> decimal dOption= 1.0;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> string val= '';</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> for(integer i=0; i<></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> {</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> val = string.valueOf(dOption);</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> skillOptions.add(new Selectoption(val,val)) ;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>dOption += 0.5;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> <span class="Apple-tab-span" style="white-space: pre;"> </span> return skillOptions;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> public List<selectoption> getSkillOptions() {</selectoption></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> List<selectoption> skillOptions = new List<selectoption>(); <span class="Apple-tab-span" style="white-space: pre;"> </span></selectoption></selectoption></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> <span class="Apple-tab-span" style="white-space: pre;"> </span> decimal dOption= 1.0;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> string val= '';</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> for(integer i=0; i<></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> {</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> val = string.valueOf(dOption);</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> skillOptions.add(new Selectoption(val,val)) ;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>dOption += 0.1;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> <span class="Apple-tab-span" style="white-space: pre;"> </span> return skillOptions;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> public void calculate(){</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> string str = string.valueOf(selctedAverage);</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> decimal tempAvg = 0;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> if(str.indexOf('.') > -1)</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> {</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>str = str.substring(0, str.indexOf('.') + 2);</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> } </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> if(str.indexOf('.5') > -1)</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> {</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>tempAvg = Double.valueOf(str);</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> else</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> {</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>tempAvg = Double.valueOf(str);</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span>tempAvg = tempAvg.round();</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> averageStar = tempAvg + 0.5; </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><span class="Apple-tab-span" style="white-space: pre;"> </span> </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> public StarRatingController(){</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> <span class="Apple-tab-span" style="white-space: pre;"> </span>selctedAverage = 1;</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> <span class="Apple-tab-span" style="white-space: pre;"> </span>averageStar = 1.5; </span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"> }</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span">}</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><br />
</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span">VF Code</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span">=============================================</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"></span></div><div style="margin-bottom: 0in;"></div><div style="margin-bottom: 0in;"></div><div style="margin-bottom: 0in;"><table cellspacing="5" cellpadding="0" border="0"><tr></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td>Select average rating :</td></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><apex:selectList value="{!selctedAverage}" size="1" id="listSelect" onchange="calculate()"></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <apex:selectOptions value="{!SkillOptions}"/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span></apex:selectList></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></td></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><tr></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td>Rating :</td></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><td valign="top"></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <apex:outputPanel id="pnlResult"></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> <div id="divStarRating"></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><apex:selectList value="{!averageStar}" size="1"></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <apex:selectOptions value="{!SkillOptionsStar}"/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span></apex:selectList></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span></div> <span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><script type="text/javascript"></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span> $(document).ready(function(){</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span>$("#divStarRating").stars({</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> inputType: "select",</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> split: 2,</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> cancelShow: false,</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> disabled : true,</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> starWidth: 17</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span>});</div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></script></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><br/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><br/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><apex:outputLabel value="selected value==> {!selctedAverage}" /><span class="Apple-tab-span" style="white-space: pre;"> </span><br/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><br/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><apex:outputLabel value="calculated value==> {!averageStar}" /></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span></apex:outputPanel><span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></td></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></tr></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span></table><span class="Apple-tab-span" style="white-space: pre;"> </span></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span> <span class="Apple-tab-span" style="white-space: pre;"> </span><apex:actionFunction name="calculate" action="{!calculate}" rerender="pnlResult" status="calStatus"/></div><div style="margin-bottom: 0in;"><span class="Apple-tab-span" style="white-space: pre;"> </span><apex:actionStatus startText="Please wait..." id="calStatus"/></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><a href="http://devaccountsite-developer-edition.ap1.force.com/StarRating">view demo</a></span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><br />
</span></div><div style="margin-bottom: 0in;"><span class="Apple-style-span"><br />
</span></div></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com2tag:blogger.com,1999:blog-5414661301757453099.post-63095463722884864792011-01-23T19:11:00.000-08:002011-01-30T19:31:51.372-08:00Approval Process on VF Page<div dir="ltr" style="text-align: left;" trbidi="on"><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">Take action approve/reject through custom VF page.</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">Generally to approve or reject an approval process standard way is used, but it’s quite interesting to access a record on custom VF page & approve/reject the record from this page. Here is the sample for this – </span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">For this two objects are required one is master & other is detail. Let's say these two objects are professional object [Master] & review object [detail].</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">In the detail object there will be a field "Submitted_For__c" lookup (user) field. This field will be used for mapping to which user this review will be submitted.</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">Now coming to the code<br />
</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">===============================================<br />
</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">To access all review object for currently logged in user –</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">List<review__c> listOfAllReviewObjects = new List<review__c>([Select r.Proffesional_Info__c, r.Name, r.Id From Review__c r where r.User_SumittedFor__c = : UserInfo.getUserId() order by Id asc limit 1000 ]);</review__c></review__c></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: #cc9933;">//iterate this list & create a set of listOfAllReviewObjects id’s. Let’s say name is “setOfAllReviewObjects”</span></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: black;">now to access all approval process for currently logged in user</span></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: black;">List<processinstance> listProcessInstance = new List<processinstance>([Select p.Id, p.Status, p.TargetObjectId, (Select ActorId, Comments, OriginalActorId, StepStatus From Steps order by CreatedDate asc) from ProcessInstance p where p.TargetObjectId in : setOfAllReviewObjects limit 1000]);</processinstance></processinstance></span></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: black;">for(ProcessInstance pi:listProcessInstance){<br />
objPi = new processInst();//here processInst is a custom class<br />
objPi.apprProcId = pi.Id;<br />
objPi.status = pi.Status;<br />
if(pi.Steps.Size()>0)<br />
{<br />
<span style="color: #996633;">//if object is approved/rejected, than Process Steps will have two entries </span><br />
if(pi.Steps.Size()>1)<br />
{ <span style="color: #cc9933;"> //these are the approved or pending records & size of steps will be greater than 1 in this case, initially there will be one entry in steps if no action taken on the record by approver</span><br />
objPi.actorUserId = pi.Steps.get(1).ActorId;<br />
objPi.reviewerName = mapReview.get(pi.TargetObjectId).Name;<br />
objPi.reviwerId = pi.TargetObjectId;<br />
objPi.originalActorUserId = pi.Steps.get(1).OriginalActorId;<br />
objPi.comments = pi.Steps.get(1).Comments;<br />
}<br />
else<br />
{ <span style="color: #cc9933;">//all records which are submitted but pending to approve.</span> <br />
</span></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: black;"> objPi.actorUserId = pi.Steps.get(0).ActorId;<br />
objPi.reviewerName = mapReview.get(pi.TargetObjectId).Name;<br />
objPi.reviwerId = pi.TargetObjectId;<br />
objPi.originalActorUserId = pi.Steps.get(0).OriginalActorId;<br />
objPi.comments = pi.Steps.get(0).Comments;<br />
<br />
}<br />
<br />
} <br />
if(objPi.status == 'Approved' || objPi.status == 'Rejected'){<br />
objPi.isApproved = true;<br />
}<br />
else {<br />
objPi.isApproved = false;<br />
}</span></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: black;">to show the all records for current user, VF page code is as below-</span></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: black;"></span><apex:pageBlockTable value="{!listProIns}" var="lpi" rendered="{!IF(listProIns.Size>0,true,false)}"><br />
<apex:column headerValue="Approval Id" value="{!lpi.apprProcId}" /><br />
<apex:column headerValue="Reviewer Name" value="{!lpi.reviewerName}" /><br />
<apex:column headerValue="OriginalActorId" value="{!lpi.originalActorUserId}" rendered="false" /><br />
<apex:column headerValue="Assigned Approver Name" value="{!lpi.originalActorUserName}" /><br />
<apex:column headerValue="ActorId" value="{!lpi.actorUserId}" rendered="false" /><br />
<apex:column headerValue="Actual Approver Name" value="{!lpi.actorUserName}" /><br />
<apex:column headerValue="Comments"><br />
<apex:inputTextArea id="txtComments" value="{!lpi.comments}" rendered="{!NOT(lpi.isApproved)}" cols="40" /><br />
<apex:outputLabel value="{!lpi.comments}" rendered="{!lpi.isApproved}" /><br />
</apex:column>><br />
<apex:column headerValue="Status" ><br />
<apex:selectList value="{!lpi.Status}" multiselect="false" rendered="{!NOT(lpi.isApproved)}" size="1"><br />
<apex:selectOption itemValue="NONE" itemLabel="--Action--" /><br />
<apex:selectOption itemValue="Approve" itemLabel="Approve" /><br />
<apex:selectOption itemValue="Reject" itemLabel="Reject" /><br />
</apex:selectList><br />
<apex:outputlabel value="{!lpi.Status}" rendered="{!lpi.isApproved}"/><br />
</apex:column><br />
</apex:pageBlockTable><br />
<apex:pageBlockButtons id="blockButton" location="bottom"><br />
<apex:CommandButton id="cmdButton" action="{!approvalProcessAction}" value="Save" rendered="{!IF(listProIns.Size>0,true,false)}"/><br />
</apex:pageBlockButtons></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">On the VF page the records which are in pending state will show a drop down to take action while other records are not editable.</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">Finally to approve or reject a particular record, user will select a value from drop down & click on save button, the save button apex code will be-</span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">Map<id,id> mapStepIds = new Map<id,id>();<br />
List<review__c> lstReview = new List<review__c>([Select (Select ID,ProcessInstanceId from ProcessSteps where isPending=true) from Review__c where Id in :setPendingReviewObjects]);<br />
if(lstReview.size()>0)<br />
{<br />
string id = '';<br />
integer i = 0;<br />
for(Review__c rv:lstReview)<br />
{<br />
if(rv.ProcessSteps.size() > 0)<br />
{<br />
id = rv.ProcessSteps[0].ID;<br />
if(id != null && id != '')<br />
{<br />
mapStepIds.put(rv.ProcessSteps[0].ProcessInstanceId, id);<br />
}<br />
}<br />
}<br />
<br />
}<br />
List<approval.processworkitemrequest> listReq = new List<approval.processworkitemrequest>();<br />
for(processInst pi :listProIns)<br />
{<br />
if(!pi.isApproved && pi.status != 'NONE')<br />
{<br />
Approval.Processworkitemrequest objReq = new Approval.Processworkitemrequest();<br />
objReq.setAction(pi.status);<br />
objReq.setComments(pi.comments);<br />
<span style="font-weight: bold;">objReq.setWorkitemId(mapStepIds.get(pi.apprProcId));</span><br />
listReq.add(objReq);<br />
<br />
}<br />
}<br />
if(listReq.size()>0)<br />
{<br />
List<approval.processresult> res = Approval.process(listReq);<br />
}</approval.processresult></approval.processworkitemrequest></approval.processworkitemrequest></review__c></review__c></id,id></id,id></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">While submitting the action “<span style="font-weight: bold;">setWorkitemId</span>” is the most important part, this is the process instance id.</span></div><div class="MsoNormal"><br />
<span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;"></span></div><div class="MsoNormal"><span style="font-family: "Trebuchet MS","sans-serif"; font-size: 10pt; line-height: 115%;">Enjoy!!!!</span></div></div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com0tag:blogger.com,1999:blog-5414661301757453099.post-87751169701980715302010-08-13T00:30:00.000-07:002011-01-30T19:33:23.677-08:00SalesForce-Facebook Integration<div dir="ltr" style="text-align: left;" trbidi="on"><div><apex:page></apex:page><br />
<div>While working with salesfoce-facebook intigration, I faced an issue at the very first step. The problem was fb:login-button was not rendering in IE(7 & 8) while it's rendering perfectly in safari, firefox & chrome. </div><div>After spending two days I have got the solution for this issue. Here is the solution..</div><div>1-There will be two pages two show login button.</div><div>2-In First page (FBLogin) write code to render fb:login-button but notice that in this I am not using any apex control apart from the <apex:page></apex:page></div><div>in this page below line is important to render login button</div><div></div><div><br />
</div></div><html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"><br />
<div><br />
</div><div><div>3-Now create a second page (ConnectFaceBook) and include page-1 in a iframe.</div><div><br />
</div><div><br />
</div><div>Now check it in IE..It's working now :)</div><div><br />
</div><div>here is the code of both pages-</div><div><br />
</div><div>here is the code of both pages-</div><div><br />
</div><div>page -1 (FBLogin) </div><div>===============================</div></div><div><div><apex:page sidebar="false" showHeader="false"></div><div><html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"></div><div><head><title>FB Login</title></div><div></head></div><div><body></div><div><div id="fConnect"></div><div><div xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"></div><div><div id="user"></div><div><fb:login-button v="2" length="long" autologoutlink="false">Connect</fb:login- button></div><div></div></div><div></div></div><div><div id="fb-root"></div><div></div> </div><div><br />
</div><div><script></div><div><br />
</div><div>window.fbAsyncInit =</div><div>function() {FB.init({appId: "Your App Id",</div><div>xfbml: true,</div><div>status: true});</div><div>};</div><div><br />
</div><div>(function()</div><div>{</div><div>var elem = document.createElement('script');</div><div>elem.type = 'text/javascript';</div><div>elem.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';</div><div>elem.async = true;</div><div>var ctrl = document.getElementById('fb-root');</div><div>ctrl.appendChild(elem);</div><div>}());</div><div></script></div><div></div> </div><div></body></div><div></html></div><div></apex:Page></div></div><div><br />
</div><div><br />
</div><br />
<br />
<br />
page -2 (ConnectFaceBook)<br />
===========================================<br />
<apex:page controller="ConnectFaceBookController" showHeader="false" sidebar="false" cache="false" id="page1" ><br />
<br />
<apex:form id="form1"><br />
<br />
<apex:pageBlock id="block1"><br />
<br />
<apex:iframe src="/apex/FBLogin" id="frame1"> <br />
<br />
</apex:iframe><br />
<br />
</apex:pageBlock> <br />
<br />
</apex:form><br />
<br />
</apex:page><br />
<br />
<br />
<br />
<br />
Thanks<br />
Kapil Goutam</div>Anonymoushttp://www.blogger.com/profile/01176153043310117367noreply@blogger.com2