Ads

Tuesday 9 July 2013

How to fetch Contact details from Opportunity using SOQL in Salesforce?

Query:

SELECT Id, Opportunity.Name, Opportunity.OrderNumber__c, Opportunity.Approval_Status__c, Contact.Email, Contact.Name FROM OpportunityContactRole

Output:


REQUIRED CHECKBOX VALIDATION?

So we now how to enable a required field in a record, but how about making a requried checkbox in your Salesforce form? well it's simple and here is how to do it:

Field 1: Lookup field called : "Account"
Field 2: Date field called "Date"
Field 3: Date field called "Expected Completion Date"
Field4: Checkbox called "Review""

AND(Review__c = FALSE,
OR(
NOT(ISBLANK(Account__c)),
NOT(ISBLANK(Date__c)),
NOT(ISBLANK(Expected_Completion__Date__c))))


and now, If the user enters data in to any one, any two, or all three fields, but does NOT check the box, an error will be thrown.

"SYSTEM.QUERYEXCEPTION: LIST HAS NO ROWS FOR ASSIGNMENT TO SOBJECT"

So I was quering Account a = [Select name from account where id=: strld];
and an exception was thrown: System.QueryExceptoin: List has no rows for assignment to SObject.

Here is the mistake I made and how to fix it:

List<Account>lst = [Select name from account where id=: strld];



WORKBENCH FOR SALESFORCE ?

What is WorkBench ?

Here is the another interesting GUI based tool for Salesforce though announced in Dreamforce before,  this is a free tool from Salesforce.com and not just limited for developers. Other than developer related offering, this tool leverage bunch of different features that you can access through web-based UI to work with Salesforce


Workbench pleasant features 


  • Query the results, download bulk XML and .csv files 
  • Pretty structured information is provided alike Data Loader
  • Offer more data load options than data loader
  • Offer tons of options for developers
  • Handy and web based tool, with easy access to both Production and Sandbox 
  • Provided with Chrome extension and Firefox Add-on to ease the life 


Some Limitations
  • Can't save the data load mapping, which is turn-off
  • Can't schedule, no scheduled options



Workbench is insanely powerful tool for admins and developer to interact with Salesforce.com. This purely web-based tool that uses oauth to connect your salesforce org. The WorkBench use force.com API and supports bulk api calls, rest call, streaming data and surprisingly these all do not end here. The best feature I like about this application is SOQL query calls from to Salesforce cloud right away with pretty interactive interface

You can query, manipulate data and the metadata in Salesforce org, this also leverage advance features like debug logs and backward compatibility testing and single sign-on integration




Query Results and Pagination 

Query results are shown there itself while in the old versions, the users were required to jump from page to page to retrieve records,  but now with pagination support, the row number on SOQL query results continue from page to page and make data view pretty easy







Browser Support 


Workbench comes with chrome extension that ease the access, and in no time work bench is ready to use and can be pulled up right inside your favorite chrome browser



How to get started with Workbench ?













Login with your org credentials and select objects







Pull up a data using Query









Tuesday 25 June 2013

Summer13 Release Features

Some Of The available Features With summer13 are  Listed Below,

  1.Approval Processes now available in change sets and exposed through the Metadata API
  2.Publisher actions are available in change sets and are supported in both managed and unmanaged packages.
  3.Summer ’13 introduces a new computer-telephony integration (CTI) Visualforce component—     support:clickToDia.
4.Summer ’13 introduces a new Visualforce component, chatter:userPhotoUpload that lets users upload a photo to their Chatter profile page
  5.The maximum size for a SOQL query has been increased to 20,000 characters
  6.Use Chatter in Apex to build Chatter integrations and custom UIs without making HTTP callouts Because Chatter in Apex exposes many Chatter API resources as Apex classes in the ConnectApi namespace
  7.Global Actions
  8. Communities

Thursday 20 June 2013

Adding Rows Dynamically to Page block Table ?

Apex:

public class MemberPopup
{
    public List<Account> memberList {get;set;}
    public List<Account> memberAddList {get;set;}
    public String memberName {get;set;}      
    public MemberPopup()
    {
        String sql = 'SELECT Name,Company__c FROM Account';
        memberList = Database.Query(sql);
        memberAddList = new List<Account>();
        memberAddList.add(new Account());
    }  
    public void AddRow()
    {
        memberAddList.add(new Account());
    }
}



VF Page:

<apex:page controller="MemberPopup" >
<apex:form >
    <apex:pageBlock id="membAdd" >                
        <apex:pageblockSection >
            <apex:pageBlockTable value="{!memberAddList}" var="m" >
                <apex:column headerValue="Member Name">
                    <apex:inputField value="{!m.Name}"/>
                </apex:column>
                <apex:column headerValue="Mobile Number">
                    <apex:inputField value="{!m.Company__c}"/>
                </apex:column>
                <apex:column headerValue="eMail Id">
                    <apex:inputField value="{!m.Account_Status__c}"/>
                </apex:column>
            </apex:pageBlockTable>
            <br/><apex:commandLink value="Add Row" action="{!addRow}" reRender="membAdd"/>      
        </apex:pageblockSection>      
        <apex:pageblockSection columns="1" >
            <apex:pageblockSectionItem >
                <apex:commandButton value="Save" />
                <apex:commandButton value="Cancel" />
            </apex:pageblockSectionItem>       
        </apex:pageblockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>



how to get a picklist values in apex controller?

Apex:
public class PicklistController{

    public Lead lead{get;set;}
    public List<SelectOption> statusOptions {get;set;}
   
    // Constructor called when page is accessed.
    public PicklistController() {   
        lead = new Lead();       
        statusOptions = new List<SelectOption>();

        // Use DescribeFieldResult object to retrieve status field.
        Schema.DescribeFieldResult statusFieldDescription =  Lead. Status.getDescribe();
        // For each picklist value, create a new select option
        for (Schema.Picklistentry  picklistEntry: statusFieldDescription.getPicklistValues())
{
            statusOptions.add(new SelectOption( pickListEntry.getValue(),pickListEntry.getLabel()));
            // obtain and assign default value
         
        }    
    }
}

VF Page:
<apex:page controller="PicklistController">
    Please selectValue:
    <apex:form >
        <apex:selectList size="1" value="{!led.Status}">
            <apex:selectOptions value="{!statusOptions}"/>
        </apex:selectList>
    </apex:form>  
</apex:page>

Screen Shot: