• Le Nguyen
  • NEWBIE
  • 235 Points
  • Member since 2014
  • Senior Salesforce Developer
  • Skedulo


  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 38
    Replies
@isTest
public class AssetTriggerTest2 {

    @isTest static void test(){
        
        Account acc = new Account();
        acc.Name = 'farah test';
        insert acc;
        
        Opportunity opp = new Opportunity();
        opp.Name = 'tests';
        opp.CloseDate = Date.today();
        opp.StageName ='Demo';
        opp.AccountId = acc.Id;
        opp.Type='New';
        opp.Demo_Date__c = Date.today();
        opp.New_Vehicle_Feed_Provider__c ='AutoFunds';
        insert opp;
        
        Product2 p1 = new Product2();
        p1.Family = '360 Suite';
        p1.IsActive = true;
        p1.Name ='360 Suite';    
        insert p1;
        
        Id pricebookId = Test.getStandardPricebookId();
        PricebookEntry pb1 = new PricebookEntry();
        pb1.Product2Id =p1.Id;
        pb1.Pricebook2Id = pricebookId;
        pb1.UnitPrice = 100.00;
        pb1.IsActive = true;
        insert pb1;
        
        
        OpportunityLineItem oli = new OpportunityLineItem(
                                                 OpportunityId = opp.Id,
                                                 Quantity = 5,
                                                 PricebookEntryId = pb1.Id,
                                                 TotalPrice = Quantity * pb1.UnitPrice
                                                                                    );
        insert oli;
        

        opp.StageName = 'Closed Won';
        update opp;
        
       
        
    }
    
}




error
Variable does not exist: Quantity


although it does exist and when i added a value to it it worked fine

trigger Updateinvoicestatus on Line_Item__c (after insert,after update) {
trigger Updateinvoicestatus on Line_Item__c (after insert,after update) {
  
    Invoice_Statement__c[] I = new list<Invoice_Statement__c>();
    for(Line_Item__c ln: trigger.new)  {     
        Invoice_Statement__c INV= new Invoice_Statement__c(id = ln.Invoice_Statement__c);
        List<Line_Item__c>Lnv=[select id,Name from Line_Item__c where Invoice_statement__c =:INV.id];
        if(Lnv.size()==2){
            INV.status__c='Closed';
             I.add(INV);
             }
            if(lnv.size()==3){
            ln.addError('You cant add more then five item');
           
        }
        
       
    }  
     Update I;
    

}
Plz give Suggestion
Hello friends
I have search page, I enter account name and it will fetch relevant fields
I have given code in Visual force page and apex class
<apex:page standardController="Account"
           extensions="MySearch">
           tabStyle="Account">
          
 <apex:form>
 
       <apex:inputText value="{!searchstring}"/>
      
       <apex:commandButton value="{!SearchAccount}"
                           title="Account Search}"/>
                          
       <apex:pageBlock title="Account Info">
      
           <apex:pageBlockTable value="{!accts}"
                                var="a">
                               
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
               <apex:column value="{!a.Industry}"/>          
          
           </apex:pageBlockTable>
      
       </apex:pageBlock>
 
 </apex:form>
  </apex:page>

public class MySearch
{
    list<Account> accts;
    public String searchstring{get;set;}
    public MySearch(ApexPages.StandardController controller)
    {
    }
    public list<Account> getaccts()
    {
       return accts;
    }
      
    public PageReference SearchAccount()
    {
       accts = (list<Account>) [FIND :searchstring IN ALL FIELDS RETURNING Account(Name, Type, Industry)];
       return null;
    }
   
}
​​
when I compile apex class I am getting an error as : "Compile Error: Incompatible types since an instance of List<List<SObject>> is never an instance of List<Account> at line 18 column 16​

Please let me know how I can resolve this​

thanks
sonali
 
Hi All,
I have wrote a trigger on opportunity to update account fields, I want to populate account field(MaxoppName__c) with opportunity name which has maximum Amount below is my code, but it is not working
trigger SumAmount_Count_MaxOpportunity on Opportunity (after insert,after update) {
List<Account> Ac = new List<Account>();
Map<String, Decimal> M = new Map<String, Decimal>();  
    set<Id> accId = new set<Id>();
    for(Opportunity objOpp: trigger.new){
            accId.add(objOpp.AccountId);
        }
    Decimal Sum;
    Integer Count;
    for(Account Acc : [SELECT Id,Name,(SELECT Id,Name,Amount FROM Opportunities) 
                              FROM Account WHERE Id IN : accId]){
        Sum=0;
        Count=0;
        for(Opportunity Opp: Acc.Opportunities){
               M.put(opp.Name, opp.Amount);
                Sum += Opp.Amount ;
                Count++;
           
            List<Decimal> l = m.values();
            for(integer i=0; i<l.size(); i++){
                Decimal Max;
                if (Max < l[i]){
                    Max = l[i];
                    opportunity op = [select id, name from opportunity where Amount =: Max];
                    
                     acc.MaxoppName__c = op.name;
                            }
                      }
                    }
            Acc.Amount__c = Sum;
            Acc.OpportunityCount__c = Count;
            Ac.add(Acc);
    }
    update Ac;
}
other fields are updating but not MaxoppName__c Please give suggesions.
 
HI ,

I have a Parent Object (Client Site) and Child Object (Client Supplier ). What i am trying to acheive is i am trying to create 1 parent and multiple child records at the same time .Everything is working perfectly except I have one issue while i cretae a parent 1 Child record is created by deafult even if i do not want to . 
public class AddClientSupplier {

    ApexPages.StandardController sc;      
    public Client_Site__c acct{get;set;}
    public Integer marker=2;
    public Integer selectedClientSupplier{get;set;}
    public List<WrapperClass> lClientSuppliers{get;set;}
    public AddClientSupplier(ApexPages.StandardController controller) {
        this.acct = (Client_Site__c)controller.getRecord();
        sc=controller;
        lClientSuppliers=new List<WrapperClass>();
        Client_Supplier__c c=new Client_Supplier__c();
        lClientSuppliers.add(new WrapperClass(c,1));
    }
    public PageReference deleteClientSupplier(){
        Integer x=-1;
        for(WrapperClass wc:lClientSuppliers){
            x++;
            if(wc.counter==selectedClientSupplier){
                System.debug('-->selected ClientSupplier:'+selectedClientSupplier+'  position:'+x);
                break;
            }
        }
       lClientSuppliers.remove(x);
        return null;
    }
    public PageReference saveClientSite(){
        Database.SaveResult sr = Database.insert(acct, false);
        Id idey=sr.getId();
        List<Client_Supplier__c> ClientSupplierList=new List<Client_Supplier__c>();

        for(WrapperClass wc:lClientSuppliers){

            Client_Supplier__c c=new Client_Supplier__c();
         c.Is_This_a_New_or_Incumbent_Supplier__c=wc.c.Is_This_a_New_or_Incumbe           nt_Supplier__c;
        c.Skill_Type__c=wc.c.Skill_Type__c;
        c.Supplier_Name__c=wc.c.Supplier_Name__c;
        c.Will_Manpower_Manage_This_Supplier__c=wc.c.Will_Manpower_Manage_Thi        s_Supplier__c;     
        c.Client_Site__c=idey;
        ClientSupplierList.add(c);
        }
        insert ClientSupplierList;
        
         return(new PageReference('/'+sr.id).setRedirect(True));       
 

    }
    public PageReference addAClientSupplier(){
        
        Client_Supplier__c c=new Client_Supplier__c();
        lClientSuppliers.add(new WrapperClass(c,marker));        
        marker=marker+1;
        return null;
    }
    public class WrapperClass{
        public Integer counter{get;set;}
        public Client_Supplier__c c{get;set;}
        public WrapperClass(Client_Supplier__c cntc,Integer i){
            this.c=cntc;
            this.counter=i;
        }
    }
}
 
<apex:page standardController="Client_Site__c" extensions="AddClientSupplier,ClientSiteExt" tabStyle="Client_Site__c">
<apex:form id="myForm" >

<apex:sectionHeader title="New Client Site" />
<apex:pageBlock title=" Client Site Edit" mode="edit">

<apex:pageBlockButtons location="top" >
                        <apex:commandButton value="Save" action="{!saveClientSite}" />
                        <apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Information" columns="2">
  
    <apex:inputField value="{!Client_Site__c.Client_Site_Name__c}" taborderhint="1"/>
    <apex:inputField value="{!Client_Site__c.Client_Discovery__c}" taborderhint="6"/>
    <apex:inputField value="{!Client_Site__c.City__c}" taborderhint="2"/>
    <apex:inputField value="{!Client_Site__c.Number_of_Shifts__c}" taborderhint="7"/>
    <apex:inputField value="{!Client_Site__c.State__c}" taborderhint="3"/>
    <apex:inputField value="{!Client_Site__c.Number_of_Team_Leads__c}" taborderhint="8"/>
    <apex:inputField value="{!Client_Site__c.Head_count__c}" taborderhint="4"/>
    <apex:inputField value="{!Client_Site__c.Number_of_On_Site_Managers__c}" taborderhint="9"/>
    <apex:inputField value="{!Client_Site__c.Job_Titles__c}" taborderhint="5"/>
    <apex:inputField value="{!Client_Site__c.Union_or_Non_Union__c}" taborderhint="10"/>
  
  </apex:pageBlockSection>
<apex:pageBlockSection title="Client Suppliers" columns="4">
</apex:pageBlockSection>
     <apex:repeat value="{!lClientSuppliers}" var="x">
     <apex:panelGrid columns="6">
     <apex:panelGrid >
     <apex:facet name="header">Client Supplier Name</apex:facet>
     <apex:inputField value="{!x.c.Supplier_Name__c}" style="width:200px" />
     </apex:panelGrid>
     <apex:panelGrid >
     <apex:facet name="header">Is This a New or Incumbent Supplier?y</apex:facet>
     <apex:inputField value="{!x.c.Is_This_a_New_or_Incumbent_Supplier__c}" style="width:200px" />  
     </apex:panelGrid>  
     <apex:panelGrid >
     <apex:facet name="header">Skill Type</apex:facet>
     <apex:inputField value="{!x.c.Skill_Type__c}" style="width:200px"/> 
     </apex:panelGrid>
     <apex:panelGrid >
     <apex:facet name="header"> Will Manpower manage this supplier?</apex:facet>
     <apex:inputField value="{!x.c.Will_Manpower_Manage_This_Supplier__c}" style="width:200px" />
     </apex:panelGrid>
     <apex:panelGrid >
     </apex:panelGrid>    
    <apex:commandButton action="{!deleteClientSupplier}" style="Button" value="Delete ClientSite" reRender="myForm" immediate="true">
    
<apex:param value="{!x.counter}" name="selected"
assignTo="{!selectedContact}"/>
</apex:commandButton>      
    </apex:panelGrid> 
    </apex:repeat>   
    
    <apex:pageBlockButtons location="bottom">
    
     <apex:panelGrid ></apex:panelGrid>
    <apex:commandButton value="Add Client Supplier" action="{!addAClientSupplier}" reRender="myForm" immediate="true" />    
    <apex:commandButton value="Save" action="{!saveClientSite}"  />
    <apex:commandButton value="Cancel" action="{!cancel}"/>
   </apex:pageBlockButtons>
  </apex:pageBlock>
  </apex:form>
</apex:page>

User-added image
Hello,

I want to get the value of a column before and after the update.
trigger test on Custom_Object__c (after insert, after update, before delete) {
    
    List <Custom_Object__c> item = new List <Custom_Object__c>();
    
    for (Custom_Object__c w: trigger.new) {
        String Column1 = w.Column1__c;
    }
}

In the above trigger i get the value of Column1__c after update.

I assume that doing below changes will get me value before update
trigger test on Custom_Object__c (before insert, before update, before delete) {
	
}

I want to detect values in a single trigger that what is the value befpre update and after update.
Is there any way to do it.


Hi all,

I override delete button in contact object but I can not find that button when package the apps. Can any one help me ?
User-added imageUser-added image
 
Hi All ,
 i have a trigger in which I am getting error.
Trigger_Contact: execution of AfterInsert caused by: System.NullPointerException: Argument cannot be null.:
my helper class is given below:-
public class ContactTriggerHelper {
    
    public static List<Contact> newContact = new List<Contact>();
    public static List<Contact> oldContact = new List<Contact>();
    public static Map<Id, Contact> newMapContact = new Map<Id, Contact>();
    public static Map<Id, Contact> oldMapContact = new Map<Id, Contact>();
 
    public static void RollupAmount(){
        System.debug('Contact Method');
        Set<Id> Accids = new Set<Id>();
        for(Contact con : newContact){
            System.debug('Contact loopSET');
            Accids.add(Con.Accountid);
        }
        List<Account> accListToUpdate = new List<Account>();
        Map<Id,List<Contact>> mapAccountIdToAccount = new map<Id,List<Contact>>();
        // creating map with account id as key and contact as list
        for(Contact con:newContact)
        {
            if(mapAccountIdToAccount.containsKey(con.AccountId))
            {   
                mapAccountIdToAccount.get(con.AccountId).add(con);
                
            }
            else 
            {   
                mapAccountIdToAccount.put(con.AccountId,new list<contact>{con}); 
            }
        }
        for(Account acc : [select id,Rollup_Amount__c,Name,
                           (select id,Name,Amount_x__c,Type__c,Amount_Y__c from Contacts) 
                           from Account 
                           where id IN: Accids]){
                               
                                   for(Contact con : mapAccountIdToAccount.get(acc.id)){
                                       System.debug('Contact loop');
                                       if(Con.Amount_x__c != null && con.Type__c == 'Positive'){
                                           acc.Rollup_X__c = con.Amount_x__c;
                                           System.debug('+here in x');
                                       }
                                       if(Con.Amount_Y__c != null && con.Type__c == 'Negative'){
                                           acc.Rollup_Y__c = con.Amount_Y__c;
                                           System.debug('+here in Y');
                                       }
                                       acc.Rollup_Amount__c = con.Amount_x__c + con.Amount_Y__c;
                                  
                               }
                               accListToUpdate.add(acc);
                               System.debug('List to update'+accListToUpdate);
                           }
        if(accListToUpdate.Size() > 0){
            update accListToUpdate;
        }
    }
}

how to solve this error?
version 47

Given
SELECT Id, Name, (SELECT Last_Contact_Method__c FROM Contacts ) FROM Account

and
SELECT Id, Status, WhatId FROM Task
where Task.WhatId =  account.Id from the above query

how would I nest the downward SOQLs to achieve
 
Select Id, Status, Email_Direction__c, (SELECT Name, (SELECT Last_Contact_Method__c FROM Contacts ) FROM ???? ) FROM Task

I've tried some variations of WhatId like
  • What
  • Whats
  • WhatId
  • WhatIds
  • What__r
  • Whats__r
to no avail. 

 
 Method Snipet :
 
 Map<String,Decimal> typeAmonutMap= new Map<String,Decimal>();
                  for(items__c Item:LineItem){
                      if(typeAmonutMap.containsKey(Item.Type__c)){  
                           } 
                           
            typeAmonutMap.put(Item.Type__c,Item.Amount__c);
        system.debug('typeAmonutMap====' +typeAmonutMap);
==>  // getting  type=A     Amount=3
                         type=A      amount=4
                         type=B      Amount= 6                                                                            type=B       Amount=9
                         type=B      amount=3
                         type=C     amount=99
                                                                                           

I need to insert above record to the related object like below:

Record1 

type=A amount=7 (3+4)

Record2

Type=B  Amount=18 (6+9+3)        

Record3

Type=C amount=99

and so on.    

Please help me to complete the method.

Hi guys!

I am getting the below error on this test. class:

Error: STANDARD_PRICE_NOT_DEFINED, No standard price defined for this product: []

 

Code:

@isTest
private class ActiveAccountTest{
    static testmethod void validateActiveAccount()
    {
        Account acc = new Account();
        acc.name= 'test';
        insert acc;
        
        Product2 newProd = new Product2 (Name = 'Test Product', ProductLine__c ='Test Product Line');
		insert newProd;
        
        Opportunity oppObj = new Opportunity(Name = 'TestOpp',AccountID = acc.Id,Amount = 2000,CloseDate=Date.today(),StageName='A - Purchase / Close Won', MarketingGeneratedType__c = 'Sales');
		insert oppObj;    
        
    	Pricebook2 customPB = new Pricebook2(Name='Test Product', isActive=true);
        insert customPB;
        
        PriceBookEntry pbEntry = new PriceBookEntry(UnitPrice = 100.00, PriceBook2Id = customPB.Id, Product2Id = newProd.Id, IsActive = true, UseStandardPrice = false);
		insert pbEntry ;

		OpportunityLineItem oppLine = new OpportunityLineItem(pricebookentryid=pbEntry.Id,TotalPrice=2000,Quantity = 1,OpportunityID = oppObj.Id);
		insert oppLine;
        
        Test.startTest();
            Account acct4 = [Select custombox__c from Account limit 1];
        Test.stopTest();
         }
}
Can anyone help with this? Any hints would be appreciated! 
@isTest
public class AssetTriggerTest2 {

    @isTest static void test(){
        
        Account acc = new Account();
        acc.Name = 'farah test';
        insert acc;
        
        Opportunity opp = new Opportunity();
        opp.Name = 'tests';
        opp.CloseDate = Date.today();
        opp.StageName ='Demo';
        opp.AccountId = acc.Id;
        opp.Type='New';
        opp.Demo_Date__c = Date.today();
        opp.New_Vehicle_Feed_Provider__c ='AutoFunds';
        insert opp;
        
        Product2 p1 = new Product2();
        p1.Family = '360 Suite';
        p1.IsActive = true;
        p1.Name ='360 Suite';    
        insert p1;
        
        Id pricebookId = Test.getStandardPricebookId();
        PricebookEntry pb1 = new PricebookEntry();
        pb1.Product2Id =p1.Id;
        pb1.Pricebook2Id = pricebookId;
        pb1.UnitPrice = 100.00;
        pb1.IsActive = true;
        insert pb1;
        
        
        OpportunityLineItem oli = new OpportunityLineItem(
                                                 OpportunityId = opp.Id,
                                                 Quantity = 5,
                                                 PricebookEntryId = pb1.Id,
                                                 TotalPrice = Quantity * pb1.UnitPrice
                                                                                    );
        insert oli;
        

        opp.StageName = 'Closed Won';
        update opp;
        
       
        
    }
    
}




error
Variable does not exist: Quantity


although it does exist and when i added a value to it it worked fine
Hi Everyone,
I have a issue in a customer, where we have 2 portals installed, and 2 different sso solutions at the same time.
Regular salesforce users log in through login.salesforce.com or custom url.
Customers from portal 1 go through IDP 1
Customer from portal 2 o trough IDP 2
Both IDP SSO configs are SP initiated (they have to start on salesforce).
My issue is:
I need a way to avoid going to the login page and actively chose one of the logins methods.
Salesforce generate the login links as follows:

https://my.custom.salesforce.domain/saml/authn-request.jsp?saml_request_id=_2CAAAAVZTcY0mME8wbTAwMDAwMDA0Qzk0AAAAypQs87MjXfKGfnOM29wBsHYId_Alz7ZZxK9jm0Sw2ElCsi4NGRR0OeIj1-asA8CLNDxFCpFjK3Cu4pxu031lK7RQaxwGRPuw4eI9nnPtleFYfR_5_eIXAAE0Dcp7zHjceZXj1q7Ivl5_Prgc0wDl7YmXkt53qOVr8bJ2oAPtR-CMj-_XB_KDi7URAcJnjWDvsseG0z15wSpCwN52nhB9QzWJWwvZTJ0BwYxS9ex4PJHrP8UPSS-pgnBiiG9oPLQp5g&saml_acs=https%3A%2F%2Fmy.custom.salesforce.org%3Fso%3D00Dm0000000CqC7&saml_binding_type=HttpPost&Issuer=https%3A%2F%2F.my.salesforce.com%2F&samlSsoConfig=SSoCOnfigId&RelayState=%2F

Is there a way to programatically chose a connection method or to manually generate the saml_request_id
Anyone has any thoughts on how achieve that without going the IDP initiated SSO???
Cheers
Hello,

Below is a code I created for validating contact deletion. But it dosent seem to work, I'm able to delete the contacts from accounts whose country is India. The trigger is active. Can someone please let me know the reason ?

1    trigger SV1 on Contact (before delete) {
2        //donot allow deletion of any contact whose account country is India
3        for (Contact cont : trigger.old){
4                    if(cont.Account.country__c == 'India'){
5                Cont.addError ('You Cannot delete the contacts of Indian accounts');
6            }
7            
8        }
9            
10    }

Regards,
Usha

 

trigger Updateinvoicestatus on Line_Item__c (after insert,after update) {
trigger Updateinvoicestatus on Line_Item__c (after insert,after update) {
  
    Invoice_Statement__c[] I = new list<Invoice_Statement__c>();
    for(Line_Item__c ln: trigger.new)  {     
        Invoice_Statement__c INV= new Invoice_Statement__c(id = ln.Invoice_Statement__c);
        List<Line_Item__c>Lnv=[select id,Name from Line_Item__c where Invoice_statement__c =:INV.id];
        if(Lnv.size()==2){
            INV.status__c='Closed';
             I.add(INV);
             }
            if(lnv.size()==3){
            ln.addError('You cant add more then five item');
           
        }
        
       
    }  
     Update I;
    

}
Plz give Suggestion
i created standard account query list in that i added CreatedDate filed and displaying format on vf like this 18/10/2014 10:13 AM but i dont want to display time here please give anybody solution.
I am trying to create a PDF version of an existing visualforce page using Bootstrap.

The visualforce page looks great until I add the renderAs="pdf" attribute to the page, which causes me to receive the following error:

"PDF generation failed. Check the page markup is valid."

When I comment out the following line of code, the pdf generates(without styling obviously)
 
<apex:stylesheet value="{!URLFOR($Resource.bootstrap, 'css/bootstrap.min.css')}" />

Has anyone come across this issue before?
  • September 30, 2015
  • Like
  • 0
I am getting "Unknown Property Error using Custom Controller" for the following VF page. I am not sure what I am missing. 

Controller: 
public with sharing class ImplementationTaskReportCtrl
{
    public String PLAN_YEAR_ID;
    public final String SHOW_IMPTS = 'show';

    public List<Implementation__c> Implementation{get;set;}
    public List<Implementation_Task__c> ImplementationTasks{get;set;}

    public ImplementationTaskReportCtrl ()
    {
        PLAN_YEAR_ID = Apexpages.currentPage().getParameters().get('Id');
        if( PLAN_YEAR_ID instanceof Id  ){intialize();}
        else{Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, Label.Invalid_Id_Error ) );}
    }

    private void intialize()
    {
        Implementation = [ SELECT Id, Name, Total_Required_Tasks__c, Plan_Year_1__c, Percent_Complete__c, Completed_Tasks__c,
                                                        ( SELECT Name, Completed_Date__c, Due_Date__c, Current_Notes__c, Historical_Notes__c FROM Implementation_Tasks__r WHERE In_Reports__c = :SHOW_IMPTS ORDER BY Due_Date__c )
                            FROM Implementation__c
                            WHERE Plan_Year_1__c = :PLAN_YEAR_ID ];

        if( Implementation == NULL || Implementation.isEmpty() )
        {
            Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, Label.No_Plan_Year_Related_IMP_Error ) );
        }
        else
        {
            ImplementationTasks = [ SELECT Name, Implementation__c, Completed_Date__c, Due_Date__c, Current_Notes__c, Historical_Notes__c FROM Implementation_Task__c
                                        WHERE Implementation__c IN :Implementation AND ( Due_Date__c < TODAY OR Due_Date__c = THIS_WEEK ) AND Completed_Date__c = null
                                        ORDER BY Due_Date__c ];
        }
    }

    public PageReference saveIMPTasksDueThisWeekAndStay ()
    {
        return save( ImplementationTasks, false );
    }

    public PageReference saveIMPTasksDueThisWeekAndGoBack ()
    {
        return save( ImplementationTasks, true );
    }

    public PageReference saveIMPTasksAndStay ()
    {
        List<Implementation_Task__c> IMPTasksToBeSaved = getAllIMPTasks();
        return save( IMPTasksToBeSaved, false );
    }

    public PageReference saveIMPTasksAndGoBack ()
    {
        List<Implementation_Task__c> IMPTasksToBeSaved = getAllIMPTasks();
        return save( IMPTasksToBeSaved, true );
    }

    private List<Implementation_Task__c> getAllIMPTasks ()
    {
        List<Implementation_Task__c> IMPTasksToBeSaved = new List<Implementation_Task__c>();
        for( Implementation__c aIMP : Implementation )
        {
            for( Implementation_Task__c aTask : aIMP.Implementation_Tasks__r )
            {
                IMPTasksToBeSaved.add( aTask );
            }
        }
        return IMPTasksToBeSaved;
    }

    private PageReference save ( List<Implementation_Task__c> IMPTasksToBeUpdated, Boolean goback )
    {
        try
        {
            update IMPTasksToBeUpdated;
        }
        catch ( Exception ex )
        {
            Apexpages.addMessage( new Apexpages.Message( ApexPages.Severity.ERROR, ex.getMessage() ) );
            return NULL;
        }
        return ( goback ?  back () : stay() );
    }

    public PageReference back()
    {
        return new PageReference ( '/' + PLAN_YEAR_ID );
    }

    private PageReference stay()
    {
        intialize();
        return NULL;
    }
    }

VF Page
<apex:page id="IMPTaskReport" controller="ImplementationTaskReportCtrl" sidebar="True" >

    <style type="text/css">
          div.pbSubheader{
            color:black !important;
            }
          .textArea-currentNotes-pbt { resize: none; width: 85%; }
    </style>
    <script>

        function setFocusOnLoad() {}
    </script>

<apex:PageMessages id="msgs"/>
<!-- <apex:includeScript value="{!$Resource.sorttableJS}"/>  -->

<apex:form >
        <apex:pageBlock title="Implementation Tasks Due This Week">
            <apex:PageBlockButtons >
                <apex:commandButton value="Save and Close" action="{!saveIMPTasksDueThisWeekAndGoBack}" rerender="msgs"/>
                <apex:commandButton value="Save and Stay" action="{!saveIMPTasksDueThisWeekAndStay}" rerender="msgs, pb, pbt-1"/>
                <apex:commandButton value="Close" action="{!back}"/>
            </apex:PageBlockButtons>
            <apex:pageBlockTable id="pbt-1" value="{!ImplementationTasks}" var="impTask">
                <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.name.label}" width="15%">
                             <apex:outputLink value="/{!IMPTask.ID}" target="_blank"> {!IMPTask.name} </apex:outputLink>
                </apex:column>
                <apex:column value="{!IMPTask.Implementation__c}" width="10%"/>
                <apex:column value="{!IMPTask.Implementation_1__c}" width="10%"/>
                <apex:column headerValue="{!$ObjectType.Implementation__c_Task__c.fields.Completed_Date__c.label}" width="5%">
                    <apex:inputField value="{!IMPTask.Completed_Date__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Implementation__c_Task__c.fields.Due_Date__c.label}"  width="10%">
                    <apex:inputField value="{!impTask.Due_Date__c}" />
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Implementation__c_Task__c.fields.Current_Notes__c.label}" >
                    <apex:inputTextArea rows="3" value="{!IMPTask.Current_Notes__c}"  styleClass="textArea-currentNotes-pbt"/>
                </apex:column>
                <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.Historical_Notes__c.label}" >
                    <apex:inputTextArea disabled="true" rows="3" value="{!IMPTask.Historical_Notes__c}" styleClass="textArea-currentNotes-pbt" />
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
        &nbsp;
        &nbsp;
        &nbsp;
        &nbsp;

        <apex:pageBlock id="pb" title="Plan Year Related Implementation Tasks">
            <apex:PageBlockButtons >
                <apex:commandButton value="Save and Close" action="{!saveIMPTasksAndGoBack}"  rerender="msgs"/>
                <apex:commandButton value="Save and Stay" action="{!saveIMPTasksAndStay}" rerender="msgs, pbt-1, pb "/>

                <apex:commandButton value="Close" action="{!back}"/>
            </apex:PageBlockButtons>

             <apex:repeat id="rpt" value="{!Implementation}" var="IMP">
             <apex:pageBlockSection title="Title" collapsible="true" rendered="false"/>
                <apex:pageBlockSection title="{!IMP.Name} : {!$ObjectType.Implementation__c.fields.Completed_Tasks__c.label}: {!IMP.Completed_Tasks__c}, {!$ObjectType.Implementation__c.fields.Total_Required_Tasks__c.label}: {!IMP.Total_Required_Tasks__c}, {!$ObjectType.Implementation__c.fields.Percent_Complete__c.label}: {!IMP.Percent_Complete__c}"
                                            columns="1"  collapsible="true">

                    <apex:pageBlockTable id="IMPtable" value="{!sos.Implementation_Task__r}" var="IMPTask">
                        <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.name.label}" width="15%">
                             <apex:outputLink value="/{!IMPTask.ID}" target="_blank"> {!IMPTask.name} </apex:outputLink>
                        </apex:column>
                        <apex:column value="{!IMPTask.Implementation_1__c}" width="15%"/>
                        <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.Completed_Date__c.label}"  width="5%">
                            <apex:inputField value="{!IMPTask.Completed_Date__c}" />
                        </apex:column>
                        <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.Due_Date__c.label}"  width="9%">
                            <apex:inputField value="{!IMPTask.Due_Date__c}" />
                        </apex:column>
                        <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.Current_Notes__c.label}" width="28%">
                            <apex:inputTextArea rows="3" value="{!IMPTask.Current_Notes__c}"  styleClass="textArea-currentNotes-pbt"/>
                        </apex:column>
                        <apex:column headerValue="{!$ObjectType.Implementation_Task__c.fields.Historical_Notes__c.label}" width="28%">
                            <apex:inputTextArea disabled="true" rows="3" value="{!IMPTask.Historical_Notes__c}" styleClass="textArea-currentNotes-pbt" />
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>

             </apex:repeat>
         </apex:pageBlock>
</apex:form>
</apex:page>

 
Hello friends
I have search page, I enter account name and it will fetch relevant fields
I have given code in Visual force page and apex class
<apex:page standardController="Account"
           extensions="MySearch">
           tabStyle="Account">
          
 <apex:form>
 
       <apex:inputText value="{!searchstring}"/>
      
       <apex:commandButton value="{!SearchAccount}"
                           title="Account Search}"/>
                          
       <apex:pageBlock title="Account Info">
      
           <apex:pageBlockTable value="{!accts}"
                                var="a">
                               
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
               <apex:column value="{!a.Industry}"/>          
          
           </apex:pageBlockTable>
      
       </apex:pageBlock>
 
 </apex:form>
  </apex:page>

public class MySearch
{
    list<Account> accts;
    public String searchstring{get;set;}
    public MySearch(ApexPages.StandardController controller)
    {
    }
    public list<Account> getaccts()
    {
       return accts;
    }
      
    public PageReference SearchAccount()
    {
       accts = (list<Account>) [FIND :searchstring IN ALL FIELDS RETURNING Account(Name, Type, Industry)];
       return null;
    }
   
}
​​
when I compile apex class I am getting an error as : "Compile Error: Incompatible types since an instance of List<List<SObject>> is never an instance of List<Account> at line 18 column 16​

Please let me know how I can resolve this​

thanks
sonali
 
I have a list of select options which I am displaying in a VF page as a multi picklist field. 
 
public List<SelectOption> getEPGName () {
        List<SelectOption> options = new List<SelectOption>();
        for (<sobject> EPG : <my query>]){
            options.add(new SelectOption(EPG.ID, EPG.<my field>));
        }
        SelectOptionSorter.doSort(options, SelectOptionSorter.FieldToSort.Label);
        return options;
}

How can I make it as a Set<string> so that the values will not be duplicated?
I have 5 fields on Object A. while loading the page, we diplay all fields( 3, 4, 5 fields are formula fields, 1 , 2 are input fields) in VF page. The problem here is, When the user is allowed to change the input values for 1 & 2 field through screen and click on save button, the formula fields are not refreshing and showing the new calculated value. If only, i choose the tab for Object A, 3, 4, 5 fields are reevaluating.
Pls tell me how to refresh the formula field in VF page