Result:
Hope this helps you!!
here I blog about the latest tech news,tricks and tips for Salesforce and other interesting topics.
for(var key in conn) { var value = key +" : "+ conn[key]; console.log("***"+value); }Option 2:
console.log(conn);
public interface custom_Interface{
void CallFirst();
Void CallSecond();
}
public class Implement_custom_Interface implements custom_Interface{
public void CallFirst(){
//
system.debug('***First**');
}
public void CallSecond(){
//
system.debug('***Second**');
}
}
public abstract class custom_Abstract{
public abstract string AbstractFirst();
public abstract string AbstractSecond();
public void noReturn(){
}
}
public class Implement_custom_Abstract extends custom_Abstract{
public override string AbstractFirst(){
system.debug('***From Abstract Extends Class***');
return null;
}
public override string AbstractSecond(){
system.debug('***From Abstract Extends Class***');
return null;
}
}
public virtual class coustom_Virtual{
public virtual void OverFirst(){
system.debug('****From Defination****');
}
public virtual void OverSecond(){
system.debug('****From Defination****');
}
}
public class Implement_coustom_Virtual extends coustom_Virtual{
public override void OverFirst(){
system.debug('!!!From Declairation!!!');
}
}
<img alt="User-added image" height="281" src="https://c.ap2.content.force.com/servlet/rtaImage?eid=00390000018kf3r&feoid=00N9000000XXXX&refid=0EM9000000XXX" width="500"></img>
This is how salesforce saves the image in the rich text box and now if we need to save any kind of image we can, as we just need the 18 digit Id of the saved image.<img src="https://c.ap2.content.force.com/servlet/servlet.FileDownload?file=00P9000000DXXXX" width="500" height="300"></img>
Wola!! now we can save any image to richtext area form apex code or by query editor. give it a try and ask me if you have any questions.<img alt=
"<image_Name>"
src=
"data:image/<image_File_Extension>;base64, <base64_Image_String>"
></img>
http://developer.force.com/cookbook/recipe/converting-a-rich-text-area-fields-image-for-api-upload
//Subclass : Wrapper Class
public class Accountwrap {
//Static Variables
public string id;
public string name;
public string Phone;
//Wrapper Class Controller
Accountwrap(string Phone, string name, string id) {
this.Phone = Phone;
this.name = name;
this.id = id;
}
}
public void getlstAccount(){
List < Accountwrap > lstwrap = new List < Accountwrap > ();
List < account > lstacc = [SELECT Id, Name, Phone FROM Account limit 2];
for (Account a: lstacc) {
Accountwrap awrap = new Accountwrap(a.Phone,a.name,a.id);
lstwrap.add(awrap);
}
strJson = JSON.serialize(lstwrap);
}
public static List<Accountwrap> parse(String str) {
system.debug('*****str*****'+str );
JSONParser parser = JSON.createParser(str);
system.debug('*****parse*****'+parser );
List<Accountwrap> jsonstatLst = new List<Accountwrap> ();
while (parser.nextToken() != null) { System.debug('Current token: ' + parser.getCurrentToken() + '****JSONToken.START_ARRAY****'+JSONToken.START_ARRAY);
if (parser.getCurrentToken() == JSONToken.START_ARRAY) {
while (parser.nextToken() != null) {
// Advance to the start object marker to
// find next invoice statement object.
if (parser.getCurrentToken() == JSONToken.START_OBJECT) {
jsonstatLst.add((Accountwrap)parser.readValueAs(Accountwrap.class));
parser.skipChildren();
}
}
}
}
return jsonstatLst;
}
<!-- Load script here -->
<apex:stylesheet value="{!URLFOR($Resource.Bootstrap, 'bootstrap-3.2.0-dist/css/bootstrap-theme.min.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.Bootstrap, 'bootstrap-3.2.0-dist/css/bootstrap.min.css')}"/>
<apex:includeScript value="https://code.jquery.com/jquery.js"/>
<apex:includeScript value="{!URLFOR($Resource.Bootstrap, 'bootstrap-3.2.0-dist/js/bootstrap.min.js')}"/>
4. Now create div and give the class of bootstrap as shown here<div class="container">
<br/>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Create Account</h3>
</div>
<div class="panel-body">
Details:
<div class="row">
<div class="col-md-4"><input id="inp1" type="text" placeholder="Account Name" class="form-control"/></div>
<div class="col-md-4"><input id="inp2" type="text" placeholder="Description" class="form-control"/></div>
<div class="col-md-4"><input id="inp3" type="text" placeholder="Phone" class="form-control"/></div>
</div>
<br/>
<br/>
<button class="btn btn-lg btn-primary btn-block" type="submit" onclick="createAcc();">Save</button>
</div>
</div>
</div>
5. Now provide this <javaScript> to the page to we can save the records.<script>
Visualforce.remoting.timeout = 120000; // Set timeout at page level
var $j = jQuery.noConflict();
function createAcc(){
$j('#basicModal2').modal('show');
var accName= $j('#inp1').val();
var accDes= $j('#inp2').val();
var accPhn= $j('#inp3').val();
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Bootstrap_Mobile_CreateAccountCon.createAccount}',accName,accDes,accPhn,handleResult);
}
function handleResult(result, event){
if (event.status) {
alert(result);
}
}
</script>
6. Now create a controller and in that create this javascriptRemoting method@RemoteAction
global static string createAccount(String accName, String accDes, String accPhn){
Account acc = new Account();
acc.name = accName;
acc.Description = accDes;
acc.Phone = accPhn;
insert acc;
return 'Success';
}
That is it, You have created a visualforce page that is using bootstrap css for view and apex controller for saving the records.<div class="checkbox col-md-4">
<label>
<input type="checkbox"> Check Box</input>
</label>
</div>
//get the checkbox values as this or you can also get a array of objects and use .each
//for multiple checkboxes id starting with inp4
function checkId(){
var inpVal= $j('#inp4').prop('checked');
alert(inpVal);
}
<apex:dynamicComponent componentValue="{!outPanel}"/>
Now in the class write this:Public transient Component.Apex.OutputPanel outPanel{get;set;}
Public List<sObject> vNewLst{get;set;}
public void getdynPan(){
vNewLst = database.query('Select Id,Name from Account limit 100');
outPanel = new Component.Apex.OutputPanel();
Component.Apex.DataTable datatable = new
Component.Apex.DataTable(var='row');
datatable.expressions.value='{!vNewLst}';
list<String> displayFieldLst= new list<String>{'Id','Name'};
Component.Apex.column clm;
Component.Apex.OutputText outText;
for(string s: displayFieldLst){
clm = new Component.Apex.column(headerValue= '' + s + '');
outText = new Component.Apex.OutputText();
outText.expressions.value = '{!row[\'' + s + '\']}';
clm.childComponents.add( outText );
datatable.childComponents.add( clm );
}
outPanel.childComponents.add( datatable );
}
What this code will do it will create a output panel and bind a datatable inside it with Id and Name columns and then display it on the page.
<apex:dynamicComponent componentValue="{!outPanel}"/>
Now in the class write this:Public transient Component.Apex.OutputPanel outPanel{get;set;}Public List<sObject> vNewLst{get;set;}public void getdynPan(){vNewLst = database.query('Select Id,Name from Account limit 100');outPanel = new Component.Apex.OutputPanel();Component.Apex.DataTable datatable = new Component.Apex.DataTable(var='row');datatable.expressions.value='{!vNewLst}';list<String> displayFieldLst= new list<String>{'Id','Name'};Component.Apex.column clm;Component.Apex.OutputText outText;for(string s: displayFieldLst){clm = new Component.Apex.column(headerValue= '' + s + '');outText = new Component.Apex.OutputText();outText.expressions.value = '{!row[\'' + s + '\']}';clm.childComponents.add( outText );datatable.childComponents.add( clm );}outPanel.childComponents.add( datatable );}
System
.RunAs
" to over come the limitations, here is an example so we can pass it:// This code runs as the admin user
Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator'];
User u = new User(Alias = 'tadmins', Email='testAdmin2014@testorg.com',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/Los_Angeles', UserName='testAdmin2014@testorg.com');
System.runAs(u) {
// here the code for test class
}
window.parent.location.href()
You can do this:var hurl = document.referrer;
So now you can access the cross domain parent url.<apex:page standardController="Account" extensions="VFBasic3"> <!-- Give the name for extension --> <apex:form ><!-- Declare a page block to contain every thing in --> <apex:pageBlock title="Account List"><!-- Declare a page block section for formating --><apex:pageBlockSection columns="1"><!-- Declare a page block table to display the data in --> <apex:PageBlockTable var="row" value="{!accList}"><!-- {!accList} is our list in the extension and row is our variable for each record --><!-- Declare a column --> <apex:column headerValue="Name"><!-- Declare a field to bind the values with--> <apex:outputField value="{!row.Name}"/> </apex:column> <apex:column headerValue="Phone"> <apex:outputField value="{!row.Phone}"/> </apex:column> <apex:column headerValue="Fax" > <apex:outputField value="{!row.Fax}"/> </apex:column> </apex:PageBlockTable> <hr/> <apex:dataTable var="row" value="{!accList}"> <apex:column headerValue="Name" width="200"> <apex:outputField value="{!row.Name}"/> </apex:column> <apex:column headerValue="Phone" width="200"> <apex:outputField value="{!row.Phone}"/> </apex:column> <apex:column headerValue="Fax" width="100"> <apex:outputField value="{!row.Fax}"/> </apex:column> </apex:dataTable> <hr/> <apex:repeat var="row" value="{!accList}"> <apex:outputField value="{!row.Name}"/> </apex:repeat> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public class VFBasic3 {
public List<Account> accList{get;set;}
//Initialize the list to avoid null pointers
public VFBasic3(ApexPages.StandardController controller) {
accList=getListAcc();
}
//Use SOQL to get records
public List<Account> getListAcc(){
List<Account> acc= [select Id,Name,Phone,Fax from Account limit 10];
return acc;
}
}
The above code is mostly self explanatory if you have any questions please post a comment.<sObject Name> = write the name without the angular parenthesis
<trigger events> = write events as before insert, before update, after insert, after update, before delete, after undelete
trigger on <sObject Name> <trigger Name> (<trigger events>) {
//Logic for trigger events
}
Now to write it for single record.trigger on Account tAccountBIBU (before insert, before update) {
//Check for events
if(trigger.isBefore && trigger.isInsert){
trigger.new[0].Description = 'Hi This is test Insert';
}
if(trigger.isBefore && trigger.isUpdate){
trigger.new[0].Description = 'Hi This is test Update';
}
}
The above code is not bulkefied as it will only effect the [0] element in the list.
trigger on Account tAccountBIBU (before insert, before update) {
//Check for events
if(trigger.isBefore && trigger.isInsert){
for(Account acc : trigger.new){
acc.Description = 'Hi This is test Insert';
}
}
if(trigger.isBefore && trigger.isUpdate){
for(Account acc : trigger.new){
acc.Description = 'Hi This is test Update';
}
}
}
Now the above code is bulkefied and will effect every record in the trigger.new listOk so this is a slity non saleforce related topic but it is very useful. It will also be helpful in facing some saleforce related task. So here it goes, if you need a proper configuration then get these things setup in your device:
1. Setup your gmail account and link it with your phone.
2. Setup your office mail in the mail application.
3. Use google calander to plan meeting and share it with people.
4. Install google drive, watsup, viber , skype, adobe reader, winzip and quick office.
5. For saleforce users install saleforce1 and saleforceA.
6. Use 3g networks for good speed.
7. Use google map to share path ways for office location or meeting halls.
Feel free to add more fetures by posting in the comments section.
The world of saleforce is so connected and vast that many time it may bappen that you have to go to other cities for work or meeting. And if you are a developer or admin it might happen you have to develop or config some of the changes that customer asked ASAP. Here are 10 things you must have so you can complete the task
1. A decient internet connection, if you have dongel its good but if not then at least a 3g enabled mobile phone with modem support. You can easly attach android to laptop via usb cable and share data connection by going in setting>tethadering port>usb tethadering.
2. Eclips helios for developing and depoloyment related task.
3. List of all username,password and security token.
4. SaleforceA installed in your device, believe me its very usefull for smaller task like resetting userpassword.
5. Saleforce1 for recent changes for mobile varification.
6. Link for database.io an online data loader.
7. Saleforce Soql guide for reference.
8. Wight list your ip if you are accessing the org from some other or new network. Note this has to be done before flying out or ask your admin to provoid you.
9. Microsoft excel or open office installed for accesing importand document. Or if not use chrome it has pdf and doc support in built.
10. If you have laptop that you carry then admin rights, some time we need to install thoes handy little software to debug webservice callout failure.
Hope this help you out have a nice day.
if (typeof(var) == 'undefined')
or
if (typeof
(var) != 'undefined')
Hope this helps some one :)
{!$Setup.CustomSettingName__c.CustomFieldName__c}
If you want to use it in code then see the below example:
CustomSetting__c cus = CustomSetting__c getInstance(Userinfo.getUserId());
string mPhone = cus.CustomField__c;
- getInstance() Returns a custom setting data set record for the current user.
- getInstance(ID) Returns the custom setting data set record for the specified user ID.
- getInstance(ID) Returns the custom setting data set record for the specified profile ID.
- getOrgDefaults() Returns the custom setting data set record for the organization.
- getValues(ID) Returns the custom setting data set record for the specified user ID.
- getValues(ID) Returns the custom setting data set for the specified profile ID.