Visualforce pages in stadard page layout salesforce

<apex:page standardController="SFDC_Employee__c">
    <style type="text/css">
        * {
          font-family: Roboto;
        }

        div.message {
          position: relative;
          padding: 1px;
          padding-left: 35px;
          margin: 20px 10px;
          box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
          background: #BBB;
          color: #FFF;
        }

        div.message.lost {
            color: white;
            background: red;
        }
       
        div.message.won {
            color: white;
            background: green;
        }
    </style>

    <link href="//fonts.googleapis.com/css?family=Roboto:300italic,400italic,400,300,600,700" rel="stylesheet" type="text/css" />
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet" />

   <div class="won message" style="display: {!IF(SFDC_Employee__c.Employee_Type__c= 'Full Time', '', 'none')}" >
      <h2>Employee : This Employee is Full Time person</h2>
    </div>
   
    <div class="lost message" style="display: {!IF(SFDC_Employee__c.Employee_Type__c= 'Part Time', '', 'none')}" >
      <h2>Employee : This Employee is Part Time person</h2>
    </div>
</apex:page>



Action status with in command button salesforce

<apex:pageBlockSection id="Buttons" columns="1" collapsible="true">
                <apex:pageBlockSectionItem id="changePasswordButton">
                    <apex:outputLabel value="" styleClass="labelCol"/>
     <apex:actionStatus id="mySaveStatus1">     
     <apex:facet name="stop">                
     <apex:commandButton action="{!changePassword}" status="mySaveStatus1" value="Change Password" disabled="{!smsResponse.jobID=='0'}" rerender="ResultsSection, Buttons"/>          
     </apex:facet>          
     <apex:facet name="start">     
     <apex:commandButton action="{!changePassword}" status="mySaveStatus1" value="Processing..." disabled="true" />
     </apex:facet>
     </apex:actionStatus>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>


dynamically Calling apex from java script custom button based on pick list value

Javascript :
-------------

{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
var ReferraAccepted = sforce.connection.query("SELECT id from {!Account.Routing_Rule__c} where AccountId ='{!Account.Id}'");
records = ReferraAccepted.getArray("records");
alert(records);
if (!records.length > 0) {
alert("There were no child records been assigned !!")
}
else {
window.open('/apex/RoutingRuleLogic?Id={!Account.Id}&objectName={!Account.Routing_Rule__c}', '_blank', 'height=600,width=600,resizable=yes,scrollbars=yes,toolbar=n‌​o,menubar=no');
}

Visualforce Page :
--------------------

<apex:page controller="RoutingRuleLogic_CLS" sidebar="false" showHeader="false">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockTable value="{!objectDetails}" var="a">
                <apex:column value="{!a.id}"/>
                <apex:column headerValue="Name">
                <apex:outputText value="{!a['name']}"/>
                </apex:column>
                <apex:column headerValue="Email">
                <apex:outputText value="{!a['email']}"/>
                </apex:column>
                <apex:column headerValue="Phone">
                <apex:outputText value="{!a['phone']}"/>
                </apex:column>
                <apex:column headerValue="Account Id">
                <apex:outputText value="{!a['Accountid']}"/>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Logic :
---------------
public with sharing class RoutingRuleLogic_CLS {
    public string objectName {get;set;}
    public String query {get;set;}  
    public RoutingRuleLogic_CLS(){
        objectName = apexpages.currentpage().getparameters().get('objectName');
        if(objectName != '' && objectName != NULL){
            getRecordsBasedOnObjectName(objectName);
        }              
    }
    public list<sObject> objectDetails {get;set;}
    public Map<String,Schema.SObjectType> schemaGlobalDescription ;
    public Schema.sObjectType objType ;
    public Map<String,Schema.SObjectField> mapFieldList;
    public void getRecordsBasedOnObjectName(string objectName){
        query = 'Select ';
        schemaGlobalDescription  = Schema.getGlobalDescribe();
        objType = schemaGlobalDescription.get(objectName);
        Schema.DescribeSObjectResult objDescribeSObjectResult = objType.getDescribe();
        mapFieldList = objDescribeSObjectResult.fields.getMap();      
        for(Schema.SObjectField field : mapFieldList.values()){
            Schema.DescribeFieldResult fieldResult = field.getDescribe();
            if(fieldResult.getName() == 'Id'){          
            }else{
                query += fieldResult.getName()+ ',';
            }
        }
        query += ' Id from '+objectName+' limit 100';      
        objectDetails = new list<sObject>();
        if(String.isNotBlank(query)){
            objectDetails = database.query(query);
        }            
    }
}

Get all the fields of sObject dynamically salesforce?

String qid = 'a0A2800000HVQSc';
String objectName = 'Employees__c';
List<String> objFields =  new List<String>();
Map<String,Schema.SObjectType> schemaGlobalDescription = Schema.getGlobalDescribe();
Schema.sObjectType objType = schemaGlobalDescription.get(objectName);
Schema.DescribeSObjectResult objDescribeSObjectResult = objType.getDescribe();
Map<String,Schema.SObjectField> mapFieldList = objDescribeSObjectResult.fields.getMap();
String commaSepratedFields ='';
for(Schema.SObjectField field : mapFieldList.values()){
    Schema.DescribeFieldResult fieldResult = field.getDescribe();
        commaSepratedFields += fieldResult.getName()+',';
}
commaSepratedFields = commaSepratedFields.substring(0,commaSepratedFields.length()-1);
String query = 'select ' + commaSepratedFields + ' from Employees__c Limit 1';
system.debug(query);
list<Employees__c> listEMP = database.query(query);
system.debug(listEMP);

Get only Id's from apex using salesforce

string ss = '01:a3E800000004XcbEAE,02:a3E800000004XjbEAE,03:a3E800000004XbtEAE,04:a3E34000000neY2EAI,05:a3E800000004XS9EAM';
List < String > strNewValue = new List < String > (ss.split(','));
string s ='';
list<string> st = new list<string>();
for (String optionName: strNewValue) {
s = s + '\''+optionName.subString(optionName.indexOf(':')+1)+'\''+',';
st.add(optionName.subString(optionName.indexOf(':')+1));
}
system.debug(s);

Featured

What is Cryptography in salesforce and what are all the algorithms provided by them ?

A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...

Popular