Thursday 10 September 2015

Put cursor at end of text input's value



<input type="text"  style="text-align:right;" onfocus="this.value = this.value;" value="120" autofocus="autofocus">

Example: 


Source: http://stackoverflow.com/questions/17780756/put-cursor-at-end-of-text-inputs-value

Sunday 6 September 2015

Working with fielsets in salesforce

Working with Field Sets Using Visualforce

<apex:page standardController="Contact">
    <apex:repeat value="{!$ObjectType.Contact.FieldSets.properNames}" var="f"> 
        <apex:outputText value="{!Contact[f]}" /><br/>
    </apex:repeat>
</apex:page>

------------------------------------------------------------------------------------

Working with Field Sets Using Apex


public class MerchandiseDetails {

    public Merchandise__c merch { get; set; }
    
    public MerchandiseDetails() {
        this.merch = getMerchandise();
    }

    public List<Schema.FieldSetMember> getFields() {
        return SObjectType.Merchandise__c.FieldSets.Dimensions.getFields();
    }

    private Merchandise__c getMerchandise() {
        String query = 'SELECT ';
        for(Schema.FieldSetMember f : this.getFields()) {
            query += f.getFieldPath() + ', ';
        }
        query += 'Id, Name FROM Merchandise__c LIMIT 1';
        return Database.query(query);
    }
}

Global Describe in salesforce



Map<String, Schema.SObjectType> mapSchemaSobjectType = Schema.getGlobalDescribe();

Set<String> setSobjets = new Set<String>();

for(Schema.SObjectType d :mapSchemaSobjectType.values())
{
       Schema.DescribeSObjectResult dSobject = d.getDescribe();
       setSobjets.add(dSobject.getName());
}

setSobjets This set will contain all the SObject name.

-----------------------------------------------------------------------------------------------------

Map<String, Schema.SObjectType> mapSchemaSObjectType = Schema.getGlobalDescribe();
Set<String> standardObjects = new Set<String>();
Set<String> customObjects = new Set<String>();
for(Schema.SObjectType objSchemaSobjectType : mapSchemaSObjectType.values())
{
    Schema.DescribeSObjectResult objResult = objSchemaSobjectType.getDescribe();
    if(!objResult.isCreateable())
      continue;
    if(objResult.isCustom() == false && objResult.getRecordTypeInfos().size() > 0)
        standardObjects.add(objResult.getName());
    else if(objResult.isCustom())
        customObjects.add(objResult.getName());
}

standardObjects - Contains set of standard objects.
customObjects - Contains set of Custom objects

Override SObject list view with Visualforce page


Create a visualforce page with standard controller and recordSetVar attribute of <apex:page>

Based on your Sobject change the StandardCopntroller and recordsetvar value.


<apex:page recordsetvar="Accounts" standardcontroller="account" tabstyle="account">
  <apex:enhancedlist customizable="True" height="600" id="YourListViewId" rowsperpage="10" type="Account">
  </apex:enhancedlist>
</apex:page>


Once visualforce page is created.
Goto Sobject detail page and goto Buttons, Links, and Actions section.
Now click edit next to list now you can see like below image


Now check radio button next to Visualforce page and select your visualforce page.
final save the changes.

Now your Sobject list view is overridden.