• Anoop yadav
  • SMARTIE
  • 1642 Points
  • Member since 2012
  • Salesforce Developer

  • Chatter
    Feed
  • 57
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 427
    Replies
Hello Expert,

I have just joined the Salesforce, and stuck in this question

I have to create a visual force page with BillingCity, BillingState and BillingCountry and a search button, based on the filter i have to display the records on the vf page.

Below is code for the visual force page

<apex:page StandardController="Account" extensions="AccountExtension">
            <apex:form>
    <apex:pageBlock id="in" title="Populate 100 Entried based on select Criteria" >
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="search" action="{!getAccountExtension}" rerender="out, in" status="status">
                    
                </apex:commandButton>    
            </apex:pageBlockButtons>
            <apex:pageBlockSection>
                <apex:inputField value="{!account.BillingState}"/>
                <apex:inputField value="{!account.BillingCity}"/>
                <apex:inputField value="{!account.BillingCountry}">
                </apex:inputField>
            </apex:pageBlockSection>
        
    </apex:pageBlock>
    </apex:form>
    <apex:pageBlock id ="out" title=" Out put">
        <apex:actionStatus   startText="updatign .... " id ="status"/>
        <apex:pageBlockSection>
            <apex:pageBlockTable value="{!accountRecords}" var="ac">
                <apex:column headervalue="Owner Name" value="{!ac.account.Name}"/>
                <apex:column headervalue = " Billing city " value="{!ac.BillingCity}"/>
                <apex:column headervalue = " Billing State " value="{!ac.BillingState}"/>
                <apex:column headervalue = " Billing Country" value="{!ac.BillingCountry}"/>
              </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Below is the code for AccountExtension
public class AccountExtension {

private Account account {get;set;}

public AccountExtension(ApexPages.StandardController  controller){
    this.account = (Account)controller.getRecord();
}
public ApexPages.StandardSetController accountRecords{
    get{
        if(accountRecords==null){
            return new ApexPages.StandardSetController(Database.getQueryLocator([Select Name, 
                                                                                        BillingCity,
                                                                                        BillingState,
                                                                                        BillingCountry 
                                                                                 from   Account 
                                                                                 where  BillingCountry like :account.BillingCountry
                                                                                 and    BillingCity     like :account.BillingCity
                                                                                 and    BillingState   like :account.BillingState
                                                                                 limit  100
                                                                                 ]));
            } 
            return accountRecords;
            
        }
        private set;
    }

    public List<Account> getAccountExtension(){
         return (List<Account>) accountRecords.getRecords();

    }
    
    }


I am not able to use accountRecords in the <apex:pageTable>. 
Kindly suggest the way to display the records on the vf page, using the filter created.

Any help will be appreciated
Hi All,

I get the Below Error When I Initialise an S Object Instance. Could Some one Please let me know how I can Initialise it.

Public Sobject NewSObject = New SObject(); 

Error: Constructor not defined: [SObject].<Constructor>()

Thanks and Regards,
Christwin
Hello, I am a complete noob to salesforce. I am trying to test the InboundEmailHandler, and I wrote the following test class:

@IsTest
private class MMmeetingemailTest
{
    Messaging.InboundEmail email1 = new Messaging.InboundEmail();
    Messaging.InboundEnvelope env1 = new Messaging.InboundEnvelope();
    
    // Create the email body
    email1.plainTextBody = 'This should become a note';
    email1.fromAddress = 'test@test.com';
    string contactEmail  = 'jsmith@salesforce.com';
    email1.subject = 'a01O000000ZW5mo';
    MMmeetingemail mmemail = new MMmeetingemail();
    
    Test.startTest();
    Messaging.InboundEmailResult result = mmemail.handleInboundEmail(email1,env1);
    Test.stopTest();    
    System.assert (result.success , 'InboundEmailResult returned a failure message');    
}

However, I keep getting the following error: "unexpected token: '=' " for the line " email1.plainTextBody = 'This should become a note'; "
I don't understand what is incorrect here, since I am simply trying to assign a value to a valid object property.

Any help is appreciated.
Thanks!
 
trigger LeadUpdate on Lead (before Update) 
{ 
   
  
 //list<lead> addhere = new list<lead>();
 for( lead ld :trigger.new)
  {
   if(ld.Do_Not_Market__c=='Blacklisted' && trigger.oldmap.get(ld.id).Do_Not_Market__c!= 'Blacklisted')
   {
    //Lead renewal = new lead();
    ld.Do_Not_Mail__c=True;
    ld.DoNotCall=True;
    ld.Email_Opt_Out__c=True;
    ld.Status='Dead';
    ld.LastName=ld.Lastname +'Renewal';
    ld.Company='ABC';
    //addhere.add(renewal);
    }
    
   
   }
   //insert addhere;
 }

only when do not market = blacklisted then it performs action
do not mail =true;
email opt out = true;


but with this test class initiall i inserted do not market = DNC this season
and then when i change do not market = blacklisted 
and test code
 i get error ....System.AssertException: Assertion Failed: Expected: true, Actual: false at line 24
@isTest
public class testLeadUpdate
{
static testMethod void updatelead()
{

lead ld = new lead();
//ld.Do_Not_Market__c='DNC This Season';
//ld.Do_Not_Mail__c=false;
//ld.Email_Opt_Out__c=false;
 //ld.LastName='Renewal';
//ld.Company='ABC';


ld.Do_Not_Market__c='DNC This Season';
ld.LastName='Renewal';
ld.Company='ABC';
insert ld;
system.assertEquals(false,ld.Do_Not_Mail__c);//line 24
system.assertEquals(false,ld.Email_Opt_Out__c);

ld.Do_Not_Market__c='Blacklisted';
update ld;
system.assertEquals(true,ld.Do_Not_Mail__c);
system.assertEquals(true,ld.Email_Opt_Out__c);






}
}

if i do like
@isTest
public class testLeadUpdate
{
static testMethod void updatelead()
{

lead ld = new lead();


ld.Do_Not_Market__c='DNC This Season';
ld.LastName='Renewal';
ld.Company='ABC';
insert ld;
system.assertEquals(false,ld.Do_Not_Mail__c);
system.assertEquals(false,ld.Email_Opt_Out__c);

ld.Do_Not_Market__c='Blacklisted';
update ld;
system.assertEquals(false,ld.Do_Not_Mail__c);
system.assertEquals(false,ld.Email_Opt_Out__c);


}
}

i get 100 % coverage...

but these fields should be set to true when do not market = blacklisted .
Hi This is my Test class its working fine Sandbox 93% coverage, but while moving to production 
i am getting this error 
FIELD_INTEGRITY_EXCEPTION, field integrity exception: PricebookEntryId (must have the same currency as the order): [PricebookEntryId] 
@isTest(seeAllData=TRUE)
    private class testSalesOrderReportGenerator {
    static testMethod void testSalesOrderReportGenerator() {
        List<OrderItem > lstoplitm= new list<OrderItem>();

  Account a = new Account(name ='testac1',BillingCity='BillingAddress',BillingCountry='India',BillingStreet='test BillingStreet',BillingPostalCode='12345',BillingState='Haryana');
        insert a;
        
        
        
Product2 prod = new Product2(Name = 'Laptop X200',Family = 'Hardware');
insert prod;

Id pricebookId = Test.getStandardPricebookId();//This is available irrespective of the state of SeeAllData.

PricebookEntry standardPrice = new PricebookEntry(Pricebook2Id = pricebookId, Product2Id = prod.Id,UnitPrice = 10000, IsActive = true);
insert standardPrice;
 
PriceBook2 pb2Standard = [select Id from Pricebook2 where isStandard=true];


PricebookEntry pbe = [ SELECT Id,Product2Id,Pricebook2Id,UnitPrice FROM PricebookEntry WHERE Pricebook2Id = :pb2Standard.Id AND isActive=true LIMIT 1 ];


 Order o = new Order(name='test opp1',Status= 'Draft' ,  AccountId=a.id,CurrencyIsoCode= 'USD',EffectiveDate = Date.today(),Pricebook2Id = pb2Standard.Id);
       insert o;
    
 OrderItem op=new OrderItem (PriceBookEntryId=pbe.Id,quantity=1,Orderid=o.id,UnitPrice=pbe.UnitPrice );
      //insert op;
     lstoplitm.add(op);
     
     
     
      insert lstoplitm;
only in after this my business logic works, please kindly help me .

thanks
 
Hi,

I have a two date field "Start Date and time" and "End date and time" How  to auto populate based on the difference between the "End Date and Time" and the "Start Date and Time"  value populate to another one field? Kindly give any idea or give any example  code

Thanks

0down votefavorite

I've a parent object (Product) and a child (Inventory). I'm trying to retrieve the value of the child object from a DisplayProducts class that I've created.
 
public class DisplayProducts {
    private Product__c products;

public DisplayProducts(Product__c item) {
    this.products = item;

}

// Properties for use in the Visualforce view
public String name {
    get { return products.Name; }
}

public String colour {
//error here 
        get { return  products.Inventorys__r.Colour__c; }

    }

public class Product {

public List<DisplayProducts> getProducts() {

        if(products == null) {
            products = new List<DisplayProducts>();

            for(Product__c item : [Select ProductID__c,Name, Price__c, (SELECT Inventory__c.Size__c, Inventory__c.Colour__c,  Inventory__c.Quantity__c FROM Product__c.Inventorys__r) 
                From Product__c WHERE ProductID__c = :prodID]) {

                products.add(new DisplayProducts(item));
            }
    }    
    return products;
}

}



I keep getting a compile error: invalid FK relationship.

I tried but it will only retrieved the first element.
products.Inventorys__r[0].Colour__c;

How do I retrieve the child item via the DisplayProducts Class? Any help will be greatly appreciated.

Thank you.
This is the error i am getting when I run this

 static Account createNewaccount()
    {
        Account newaccount= new Account(Name= 'test');
        newaccount.RecordTypeID= '012A0000000E3yA';
        insert newaccount;
        return newaccount;
        
    }
I have created Workflow rule like when the condition satisfies Email should be sent. Everything goes well but when I create record Workflow not triggering the Email. All my workflows, Email alert and template status are Active only. Do i have to make any changes?

Thank you 
   
I have created  a LogAcall  button  on opportunity page....when we click it opens Task page to create. after saving the Task  record i want to land on  Opportunity record. The 'retUrl' is not working  to land  'opportunity object home page'. (means i want to land on here  on save    'https://cs16.salesforce.com/006/o')

/00T/e?who_id={!Contact.Id}&RecordType={!Task.RecordTypeId}&tsk6={!Opportunity.Description}&tsk1={!User.Name}&tsk13 = 'Normal'&00N40000002dXt2 = {!Opportunity.Product_Interest__c}&tsk3= {!Opportunity.Name}&tsk3_lkid ={!Opportunity.Id}&tsk4={!Opportunity.Follow_Up_Date__c}&tsk5={!Opportunity.Name}&returl=/006/o
Hi
I'm deleting cases, before inserting cases through mail based on domain condition.Please help me.
trigger Auto_generated on Case (after insert) {
    List<Case> emDelList = new List<Case> ();     
    for (Case em : Trigger.New) {   // bulkified      
      List<String> mailsplit;
      String Result;
      mailsplit  = em.SuppliedEmail.Split('@');
      Result = mailsplit [1];
       if(em.SuppliedEmail != null)
        {
        if(Result.contains('gmail.com'))
          emDelList.add(em);
       } 
    }
    
delete emDelList;
}

Error: DML statement cannot operate on trigger.new or trigger.old
Hi all,

I am clicking on save button record is not inserting...

VF Page:-
------------

<apex:page standardController="Employee1__c" tabStyle="Employee1__c" extensions="Thirdware">
 <apex:form >
  <apex:pageBlock id="first">
   <apex:pageblockSection title="First Page">
    <apex:inputfield value="{!Employee1__c.FirstName__c}" />
    <apex:inputfield value="{!Employee1__c.LastName__c}" />
   </apex:pageblockSection>
 
   <apex:outputPanel id="second">
   <apex:outputPanel rendered="{!show}">
   <apex:pageBlockSection title="Second page">
   
    <apex:inputfield value="{!Employee1__c.Employee2__c}" />
    <apex:inputfield value="{!Employee1__c.Picklist__c}" /> 
    <apex:commandButton value="Approved" />
    <apex:commandButton value="Rejected" /> 
    </apex:pageBlockSection>
    </apex:outputPanel>   
    </apex:outputPanel>
 
 <apex:pageBlockButtons location="Bottom">
  <apex:actionRegion >
   <apex:commandButton value="Save" action="{!savedata}">
   <apex:actionSupport reRender="second" event="onchange"/>
   </apex:commandButton>
   </apex:actionRegion>
  </apex:pageBlockButtons>
  </apex:pageBlock>
 </apex:form>
</apex:page>


Apex class:-
----------------
public with sharing class Thirdware {

    public Boolean show{get;set;}
    public string LastName{set;get;}
    public string FirstName{set;get;} 
    public Employee1__c emp {set;get;} 
    
    public Thirdware(ApexPages.StandardController controller) {
     show = false;
    }    
    
    public void savedata(){
     emp = new Employee1__c();
     emp.FirstName__c = FirstName;
     emp.LastName__c = LastName;
     try{
     insert emp;
    }catch(Exception e){
   }
   }
    public boolean Save(){
    
     show = true;
     return null;
    }    
}


Regards
Sam
I have an apex Class that I've entered in my Sandbox, I'm trying to deploy this to my production Org but I'm getting an error saying that the code coverage is too low. I've read up on creating test classes but I'm still a bit lost. Is there any documentation not just on creating a test class but one that will show you how to create a test class that tests the code you have in the Class you are looking to deploy? 
Hi,
public class MyHelloWorld
{

 

public static void applyDiscount(Boook__c[] books)
{
for(Boook__c b:books)
b.Prise__c*=0.9;
}
}
when i am trying to executive this class it's getting error,plz urgent.


Thanks!!
Hi All,

I have a simple question about about opoortunities in account subquery. I am trying to fetch particular opportunities(based on StageName) in account subquery but the problem is that subquery is not returning All opportunities connected with particular account even without a WHERE condition.

I have:
 
SELECT ID,Name,Sales_Funnel__c,(Select Name,StageName,createdDate, id FROM Opportunities__r ShowAll order by CreatedDate desc) FROM Account WHERE id='j52gcw632x4bj43'
It is just returning 4 opportunities out of 9. I even tried with ShowAll in the query but it does not make any difference.

If I make a query for the particular opporutnity that subquery is not returning inside subquery it is normally returned and also with accounid and name etc.
 
Select CreatedDate, name, StageName, Account_Manager__c, Account.Name,accountid From Opportunity where id='g2dhjk50fjkB14g'

This particular opportunity (among other 5 that are missing) is also normally visible @ Account page layout also.

Knowing that these are standard objects I was wondering if there are any restrictions that are applied for these case scenarios.
Please Help :)

Thanks in advance.
  • November 10, 2014
  • Like
  • 0
Hi all, I was wondering if you could help me create a test class for the clontroller seen below. Any help would be appreciated,

Many thanks.
 
public class IncidentLogPopup
{ 

 public List<Incident_Log__c> memberList {get;set;}
    public List<Incident_Log__c> memberAddList {get;set;}
    public String memberName {get;set;} 
    public string searchstring {get;set;} 

    
    public PageReference cancel() {
        return null;
    }


    public IncidentLogPopup() {

    }
    
   
    public IncidentLogPopup(ApexPages.StandardController controller) {
        String sql = 'SELECT Match_Day_Ops__c, Date_Time__c, Date_Closed__c, Type__c, Priority__c, Incident__c, Reported_to__c, Reported_By__c, Opened_Closed_Status__c FROM Incident_Log__c';
        memberList = Database.Query(sql);
        memberAddList = new List<Incident_Log__c>();
        memberAddList.add(new Incident_Log__c(Match_Day_Ops__c = 'a0Gf000000111CV', Date_Time__c = DateTime.Now()));
         
        
    }
    
    public void AddRow()
    {
        memberAddList.add(new Incident_Log__c(Match_Day_Ops__c = 'a0Gf000000111CV', Date_Time__c = DateTime.Now()));
        
    } 
    
    Public Pagereference Save(){
        insert memberAddlist;
        PageReference page = new Pagereference('/a0G/o');
                     page.setRedirect(true);
            return page;
  }
   

        
   }

 

i created basic vf page to display a+b=c ....this is working fine ...but i want to dispaly the values of A,B,C in pageblocktable how can i dispaly like so.


while saving the page am getting this error :Unknown property 'Integer.a'

vf page:

<apex:page controller="integercon" >
<apex:form >
Value Of A:<apex:inputText value="{!a}"/>
Value Of B:<apex:inputText value="{!b}"/>
Value Of C<apex:inputText value="{!c}"/>
<apex:commandButton action="{!savelist}" value="click"/>
<apex:pageBlock>
<apex:pageBlockTable value="{!dispaly}" var="r">
<apex:column value="{!r.a}"/>
<apex:column value="{!r.b}"/>
<apex:column value="{!r.c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>


Class:

public with sharing class integercon {
   public integer a{get;set;}
   public integer b{get;set;}
   public integer c{get;set;}
   
   public integer dispaly{get;set;}
    
    
    public void savelist() {
        c=a+b;
        
    }
}


please help me ...with out pageblck table excution is okay...but i want to display the a,b,c values on vf page ...how can i so??

thanks in advance

<apex:page standardcontroller="METADATA_Campaign__c" extensions="CampaignPage" showHeader="false" sidebar="false">
  <style>
        body .bPageBlock .pbBody .red .pbSubheader{
            background-color:#c00000;
        }
        body .bPageBlock .pbBody .grey .pbSubheader{
            background-color:#c0c0c0;
        }
        body .bPageBlock .pbBody .grey .pbSubheader h3{
            color:#000;
        }
        body .bPageBlock .pbBody .blue .pbSubheader{
            background-color:#0000FF;
        }        
    </style>
       <apex:form >
    <apex:pageBlock title="Campaign Details">
  
                <apex:outputPanel styleClass="Red" >
                <apex:pageblockSection title="Campaign Information">
                        <apex:inputField value="{!camp.Name}"/>
     <apex:inputField value="{!camp.BRANDED__c}"/>
     <apex:inputField value="{!camp.METADATA_Status__c}"/>
     <apex:inputField value="{!camp.Program__c}"/>
     <apex:inputField value="{!camp.Therapy_Class__c}"/>
     <apex:inputField value="{!camp.Campaign_Code__c}"/>
     <apex:inputField value="{!camp.Campaign_ID__c}"/>
     <apex:inputField value="{!camp.Campaign_Type__c}"/>
     <apex:inputField value="{!camp.EndDate__c}"/>
     <apex:inputField value="{!camp.HCP__c}"/>
     <apex:inputField value="{!camp.Objective__c}"/>
     <apex:inputField value="{!camp.Description__c}"/>
     
     <apex:inputField value="{!camp.Program_ID__c}"/>
     <apex:inputField value="{!camp.StartDate__c}"/>
    
     <apex:inputField value="{!camp.Status__c}"/>
     <apex:inputField value="{!camp.Therapy_ClassID__c}"/>
     
     <apex:inputField value="{!camp.UA_CAMPAIGN_ID__c}"/>
     <apex:inputField value="{!camp.USMM__c}"/> 
                </apex:pageblockSection>
            </apex:outputPanel>
     <apex:pageBlockButtons >
    <apex:commandButton value="Save" action="{!save}"/>
   </apex:pageBlockButtons>

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

//

Above VF Page is my Custom page, when i click sava the  record not saving and showing error that 'Attempted to upsert a null list
Error is in expression '{!save}' in component <apex:commandButton> in page metadatacampaignpage: Class.CampaignPage.save: line 14, column 1


here i am attaching my Apex class please saove this... Its urgent..

Thanks in Advance

public class CampaignPage {

    public CampaignPage(ApexPages.StandardController controller) {
    }
  public Metadata_Campaign__c camp;

   public void insertcampaign(){
   camp = [select id,BRANDED__c,Campaign_Code__c,Campaign_ID__c,Campaign_Type__c,Description__c,EndDate__c,HCP__c,Objective__c,Program__c,Program_ID__c,StartDate__c,  METADATA_Status__c,Status__c,Therapy_ClassID__c,Therapy_Class__c,UA_CAMPAIGN_ID__c,USMM__c from METADATA_Campaign__c where id =: ApexPages.currentPage().getParameters().get('id')];
   }
    public Metadata_Campaign__c getcamp(){
    return camp;
 }
   public system.PageReference save() {
    Upsert camp;
  PageReference pref = new ApexPages.StandardController(camp).view();
   return pref;
  }
  }
'
Hi all,

I am having trouble creating a test class in the example below. I have never created a test class for a return SOQL Statement.

Any help would be appreciated. Thanks

My Class:
public class ITCheckList  {

public List<Match_Day_Check_List__c> getITCheckList(){
 
return [SELECT Handshake_Event_Setup__c, Access_Manager_Checks__c, Wifi_Setup__c, Ground_Catering_Till_Checks__c, Poll_Steward_System__c, Turnstile_Checks__c, 
                Press_Wifi_Checks__c, Set_Phone_Times_Fan_Centre__c, Check_Sodexo_Epos_Servers__c, IT_Systems_Readiness_PC__c, HR_Readiness_Percent__c, Stadium_Readiness_PC_1__c, 
                Steward_Comms_Checks_Complete_PC__c, Overall_Completion_Matchday__c,Lighting_to_all_areas_of_Sports_Ground__c, Fire_Alarm_System__c, Public_Address_System__c, CCTV_System__c,
                 Internal_External_Phone_System__c, Turnstile_Control_Counting_System__c, Door_Holding_Mechanism_System__c, Entry_Signage_Changed__c, H_S_Assessment_of_Broadcaster_Operation__c,
                 Set_Heating_Air_Con_in_Lounges__c, First_Aid_Room_Check__c FROM Match_Day_Check_LIst__c
                WHERE Name = 'Everton V West Ham United Goodison Park EPL 2013-05-12'];
    }
}

 

I have a Formula field named "Net Amount" (below is the formula for that)
based on record type I need to calcuated the "Net Amount"..


CASE ($RecordType.Name , 
"US Opportunity", Amount__c*0.62, 
"US Jobber Opportunity", Amount__c*0.62, 
"Authentication", Est_Opportunity_Volume__c*Est_Selling_Price__c, 
"US Opportunity - Approved", Amount__c*0.62,
"US Free Goods Opp" , Amount__c*0.62, 
"US Free Goods Opp - Approved" , Amount__c*0.62,
"US Lost Account" , Amount__c*0.62,
"AUS Record Type" , Amount__c * 12,
"US DuPont Legacy Opportunity" ,Amount__c * 0.62,
"DPC-AP" ,Amount__c * 12,
"IND-AP" , Amount__c / Contract_Duration__c,
0)

Everthing works fine until "Contract_Duration__c" is not 0 (zero) or NULL
Even if the incoming RecordType not equal to "IND-AP" and "Contract_Duration__c" is null or 0
the result is #Error!

Requesting to please help me out how to set this..
as if the recordType not equal to "IND-AP" things should work...

thanks in advance
Sunny

public class StringArrayTest
{
    public void generateStringArray()
    {
        String[] colors = new List<String>{'red','green','blue'};
        for(Integer i=0;i<colors.size();i++)
         {
             // Write value to the debug log
              System.debug(colors[i]+i);
         }
    }
}


M just fresher in SFDC...
How can i run above code.??
Thanx in Advance :)
hi guys, please explain about afeter undelete

when we will use after undelete in trigger.new?
hi ,

am creating checkbox in vf and now i want to write if else statement with checkbox enable and disable plz give me the solution
 
unable to display output on debug log after executing the program
Hello Expert,

I have just joined the Salesforce, and stuck in this question

I have to create a visual force page with BillingCity, BillingState and BillingCountry and a search button, based on the filter i have to display the records on the vf page.

Below is code for the visual force page

<apex:page StandardController="Account" extensions="AccountExtension">
            <apex:form>
    <apex:pageBlock id="in" title="Populate 100 Entried based on select Criteria" >
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="search" action="{!getAccountExtension}" rerender="out, in" status="status">
                    
                </apex:commandButton>    
            </apex:pageBlockButtons>
            <apex:pageBlockSection>
                <apex:inputField value="{!account.BillingState}"/>
                <apex:inputField value="{!account.BillingCity}"/>
                <apex:inputField value="{!account.BillingCountry}">
                </apex:inputField>
            </apex:pageBlockSection>
        
    </apex:pageBlock>
    </apex:form>
    <apex:pageBlock id ="out" title=" Out put">
        <apex:actionStatus   startText="updatign .... " id ="status"/>
        <apex:pageBlockSection>
            <apex:pageBlockTable value="{!accountRecords}" var="ac">
                <apex:column headervalue="Owner Name" value="{!ac.account.Name}"/>
                <apex:column headervalue = " Billing city " value="{!ac.BillingCity}"/>
                <apex:column headervalue = " Billing State " value="{!ac.BillingState}"/>
                <apex:column headervalue = " Billing Country" value="{!ac.BillingCountry}"/>
              </apex:pageBlockTable>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Below is the code for AccountExtension
public class AccountExtension {

private Account account {get;set;}

public AccountExtension(ApexPages.StandardController  controller){
    this.account = (Account)controller.getRecord();
}
public ApexPages.StandardSetController accountRecords{
    get{
        if(accountRecords==null){
            return new ApexPages.StandardSetController(Database.getQueryLocator([Select Name, 
                                                                                        BillingCity,
                                                                                        BillingState,
                                                                                        BillingCountry 
                                                                                 from   Account 
                                                                                 where  BillingCountry like :account.BillingCountry
                                                                                 and    BillingCity     like :account.BillingCity
                                                                                 and    BillingState   like :account.BillingState
                                                                                 limit  100
                                                                                 ]));
            } 
            return accountRecords;
            
        }
        private set;
    }

    public List<Account> getAccountExtension(){
         return (List<Account>) accountRecords.getRecords();

    }
    
    }


I am not able to use accountRecords in the <apex:pageTable>. 
Kindly suggest the way to display the records on the vf page, using the filter created.

Any help will be appreciated
Dear all, below is my code which automatically send email notificaitons when a new Event is created. If opportunity is not tagged to Event, I`m getting a System.NullpointerException. Could you please help in understanding what I`m doing wrong? I`m new to Apex 

Apex trigger NotifyOnSiteVist2 caused an unexpected exception, contact your administrator: Visitnotify: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.Visitnotify: line 29, column 1

 
Trigger Visitnotify on Event (after insert){
        
    List<Messaging.SingleEmailMessage> newEmails = new List<Messaging.SingleEmailMessage>();
    List<Id> whatIds = new List<Id>();
    List<Id> createdByIds = new List<Id>();
    for(Event e :Trigger.new)
    {
        createdByIds.add(E.CreatedByID);
        whatIds.add(E.whatId);
    }
    Map<Id, User> users = new Map<Id, User>([SELECT Id, Name from User WHERE Id in :createdByIds]);
    Map<Id, Opportunity> opportunities = new Map<Id, Opportunity>([SELECT Name, Account.Name from Opportunity WHERE Id in :whatIds]);
    for(Event e :Trigger.new){
    
    if(e.whatid != NULL){ 
            String fullTaskURL;
            String Facility;
            Datetime startDate;
            Datetime endDate;
            String Purpose;

            
            // Query to populate CreatedBy name in html template
            Id createdByID = E.CreatedByID;
            String createdByName = users.get(createdByID).Name;
                   
            // Query to populate Opportunity name in html template
            String oppID = E.whatId;  
            String oppName = opportunities.get(oppID).Name;
                                 
        if(E.Site_Visit__C ){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                
            mail.setSubject(' Alert: A New Visit Record is Created');
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId('00580000005LedR'); 
                                     
            fullTaskURL = URL.getSalesforceBaseUrl().toExternalForm() + '/' + E.Id;
            Facility = E.Facility__c;
            startDate = E.StartDateTime;
            endDate = E.EndDateTime;
            Purpose = E.Purpose_of_Visit__c;
                
   
            //Generate email template
                String emailBody;
                emailBody = '<html><body>Hi ,<br> <br> A New Site Visit Record has been created: <a href="' + fullTaskURL + '">' + E.Id + '</a><br></body></html>' + '<br> Sales VP: '+ createdByName + '<br> Opportunity/Account Name: '+ oppName + '<br> <br> Site/Facility: ' + Facility+ '<br> Purpose of Visit: ' + Purpose +  '<br> Start Date/Time: ' + StartDate +  '<br> End Date/Time: ' +endDate +  '<br> <br> Thank you <br> <br> Salesforce Admin' ;
                mail.setHtmlBody(emailBody );

            newEmails.add(mail);
        }
    }

    messaging.sendEmail(newEmails);
} }

 
public class good
{
Public string logid;
public good(ApexPages.StandardController controller)
{
    system.debug('********'+logid) // After submitting I need the same value Yes here, But it Shows NULL
}
Public page reference submit() //
{
Logid = 'Yes'; 
}
}


My problem is when i press submit button, Logid variable is assigned to Yes. But when it goes to Constructor it is Changed to Null, which affect my further codes.
How to get the same value in constructor? am i wrong anywhere? 

Hi All,

I have added a check box called "ValidateEmail" to Contact Object. When "ValidateEmail" is TRUE I want the before update and before insert trigger to check whether the EMAIL (field on Contact object) is empty or not.

If the "ValidateEmail" is TRUE and EMAIL is empty I dont want to add/update that record. Instead I want to show a validation error message. If the "ValidateEmail" is FALSE I dont want that validation.

How can I do this?

Any Help? Thanks in advance.


Iam having 3 Fields in one object

1.Picklist(Yes or No)
2.Checkbox(Marked)
3.Checkbox(Unmarked)

When ever an attachment is attached the third field will be marked if Picklist Value is YES & 2nd Checkbox is marked.
there to further problems, can someone help me, this is my code
public class OdtDetailController2 
    {

       
         public list<wrapperclass> Jonintwrapper{get;set;}
         public list<wrapperclass> Odtwrapper{get;set;}
         public Ordre_Travail__c OrdreTravail {get; set;}
        Public Double TotalNombre=0;
        Public Double TotalQuantite=0;
       Public Double Total;
       
         
         public OdtDetailController2(ApexPages.StandardController controller) 
             {
                 this.OrdreTravail = (Ordre_Travail__c)controller.getRecord();
                 OrdreTravail = [SELECT Id, Date__c, Produit__c, Nombre__c FROM Ordre_Travail__c];
                 list<JointMatProd__c> Jointure = [SELECT id, MatierePremiere__c, Quantite__c FROM JointMatProd__c WHERE produit__c = :Ordre_Travail__c.Produit__c];
                 
                 //list<Ordre_Travail__c> OrdreTravail = [SELECT id, name, Date__c, Produit__c, Nombre__c FROM Ordre_Travail__c WHERE produit__c = :Ordre_Travail__c.Produit__c];
                 //list<JointMatProd__c> Jointure = [SELECT id, MatierePremiere__c, Quantite__c FROM JointMatProd__c WHERE produit__c = :Ordre_Travail__c.Produit__c];
                 Odtwrapper = new list<wrapperclass>();
                 /*for(Ordre_Travail__c Odt: OrdreTravail)
                     {
                        Odtwrapper.add(new wrapperclass(Odt));*/
                         if(OrdreTravail.Nombre__c!=Null){
                             //TotalNombre+=odt.Nombre__c;
                             Odtwrapper.add(new wrapperclass(OrdreTravail));
                             TotalNombre+=OrdreTravail.Nombre__c;

                        } 
                    // }
                     
                 Jonintwrapper = new list<wrapperclass>();
                 for(JointMatProd__c Joint: Jointure)
                     {
                        if(Joint.Quantite__c==Null)
                        Joint.Quantite__c=0; 
                        Jonintwrapper.add(new wrapperclass(Joint,Double.ValueOf(Joint.Quantite__c*TotalNombre)));
                        
                     }
                       

              }
    
              public class wrapperclass
                  {
                       public Ordre_Travail__c ODT{get;set;}
                       public JointMatProd__c JOINT{get;set;}
                       Public Decimal Total{get;set;}
                       
                       public wrapperclass(Ordre_Travail__c OrdreTravail) 
                           {
                                this.ODT = (OrdreTravail);
                           }
                           
                       public wrapperclass(JointMatProd__c Joint,Decimal Total) 
                           {
                                this.JOINT = (Joint);
                                this.Total=Total;
                           }
                  }
    }
Here the error
Erreur : OdtDetailController2 Erreur de compilation : Invalid bind expression type of Schema.SObjectField for column of type Id à la ligne 17 colonne 136
 
i just wrote this code:

trigger updateQuant on Order__c (after insert) {


    Map <id,Item__c> ma=new Map<id,Item__c>();
    for(Order__c o:Trigger.New){
        ma.put(o.Item__c,null);
        
    for(Item__c i: [select id,Price__c,Quantity__c from Item__c where 
                                                id in:ma.keySet()])
        ma.put(i.id,i);
               
               
    for(Order__c q:Trigger.New){
        Item__c t= ma.get(q.Item__c);                                                 
        t.Quantity__c=t.Quantity__c-1;   
    }    
}
}

i tried to chage the Quantity number in the parent  item but it didn't change, where is my mistake?
thanks for the help
I need to count the working days or leave of any employee excluding the weekends,then i need to write code for same.
Hi all,

i am getting an error for the bind expression accidsLst in the below SOQL query
 
List<Contact> accidsLst=new List<Contact>();
         
         for(Contact con :newContactsLst)
         {
             contactsMap.put(con.Id,con);
         }
         
         accidsLst=[SELECT AccountId FROM Contact
                    WHERE Id IN:contactsMap.keySet()];
         
         for(Contact con :[SELECT Id,Primary_Contact__c FROM Contact
                           WHERE Id NOT IN:contactsMap.keySet() AND Primary_Contact__c=true
                           AND AccountId IN : accidsLst]) //error for accidsLst
         {
         }

Can anyone please help?

thanks
I want to give dynamic search with date filters to end user. Date input values are like 01/01/2015 and 01/05/2015 selected throught date picker. 
then i need only the records within the specified date range when user click on search button.
Hi All,

I get the Below Error When I Initialise an S Object Instance. Could Some one Please let me know how I can Initialise it.

Public Sobject NewSObject = New SObject(); 

Error: Constructor not defined: [SObject].<Constructor>()

Thanks and Regards,
Christwin
I created a custom Object "Location" , all are 3 picklists and each other dependent picklists hirarchely.  

User-added image

I am getting Duplication entries from these fields.
when i select HeadQuarter there can be multiple Areas should be enter but once i select one Area in one HeadQuarter,
the selected Area should not save again in the record .

To avoid this which criteria should i follow,

Workflow
Validation Rule
Trigger

Which one is suitable and how.

Is there any other Good Apporach .


 
Hi,

The CRM I am working has 22 Active triggers in Opportunity Object. Every time I am trying to update any thing related to Opportunity, it is giving me 101 SOQL error. Even when I deploying Class,testClass in production is giving same error.

Any idea how to deal with this situation.