• NikunjVadi
  • NEWBIE
  • 155 Points
  • Member since 2014
  • Vesta Home Services

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 23
    Questions
  • 33
    Replies
Scenario: how to display the records owned by a specific user when having multiple records owned by multiple users in the list view?
if possible, can we achieve it through UI or do we have to go for coding? any ideas or answers will be highly appreciated
i am trying to fetch fields from a aggregteresult but it is giving me error :Invalid field Time_Account_Mapping__c for SObject AggregateResult
 
Time__c tes = [select Time_Account_Mapping__c from Time__c order by LastModifiedById desc limit 1];
     
        AggregateResult obj = [Select Time_Account_Mapping__c,sum(Hours__c) from time__c group by Time_Account_Mapping__c having Time_Account_Mapping__c in (:tes.Time_Account_Mapping__c)];

	Account ppla = new Account();
        ppla.id = obj.Time_Account_Mapping__c;
        ppla.Total_Client_Hour__c=obj.sum(Hours__c);
    //    ppla.Total_Client_Hour__c = test.Unknown_Field__1;
        update ppla;
Help me out here.
Thanks
Hello,

I wonder about: Is Force.com the same as VisualForce?
  • If different, what are the main differences betwen both?
  • If the same, why do they have different names?
Thank a lot.
i want to assigned a constant value for the field stored in a string . But i am getting an error:Expression cannot be assigned 

What is wrong with :
refOpportunityItem.get(Tierfield) = -1;
Opportunityitem__c refOpportunityItem = new refOpportunityItem();

   public void tierNumbers()
    {
        if(refOpportunityItem.Number_Of_Tier__c != Null)
        {
            NumberOftier=Integer.valueOf(refOpportunityItem.Number_Of_Tier__c);
            TierField ='Upper_Quantity_Tier_2__c';
            refOpportunityItem.Upper_Quantity_Tier_2__c = -1;
------In the next row i am getting error
            refOpportunityItem.get(Tierfield) = 1;
            //refOpportunityItem.get(Tierfield);
       }
{

 
I want to redirect from another page to a section of visuaforce page:

I have used this in vf page(Definition is name of page):

<a href="#top">Go to top</a>

I have used this in the page where the button is located :
<a href="/apex/Definition#top">Test</a>

Even if i paste in address bar : https://c.na35.visual.force.com/apex/Definition?#test , still is not getting me to the sections .

It is simple in html . I dont know why it is not working on VF pages.

Thanks for looking at my problem
 
hey,

In my code when i click on command button, data is getting inserted and updated, but page isn't getting redirected after click.  
please help me out here:
code:

vf page:
<apex:page standardController="Project__c" sidebar="false" showHeader="false" extensions="ProjectTime_Controller" id="TimeTrack" standardStylesheets="true" docType="html-5.0">
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <meta name="description" content=""/>
            <meta name="author" content=""/>
    
            <title>Time Station</title>
    
            <!-- Bootstrap core CSS -->
            <apex:stylesheet value="{!URLFOR($Resource.Bootstrap3_3_2, '/bootstrap-3.3.2-dist/css/bootstrap.min.css')}" />
            <!-- Bootstrap theme -->
            <apex:stylesheet value="{!URLFOR($Resource.Bootstrap3_3_2, '/bootstrap-3.3.2-dist/css/bootstrap-theme.min.css')}" />
        </head>

        <body role="document">
            <div class="panel panel-default">
            <div class="panel-body">  
            <div class="well">
                <p>Bonjour {!$User.FirstName} {!$User.LastName}</p>
            </div>
            <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">Time Station</h3>
            </div>
            <div class="panel-body">
            
            

    <apex:includeScript value="{!$Resource.modernizr}"/>
    
    <script>
        function doTheGeoThang1()
            {
            if (Modernizr.geolocation){
                navigator.geolocation.getCurrentPosition(
                function(position) {
                    loc1(position.coords.latitude,position.coords.longitude);
                }
                );
            }
            else 
            {
                alert ("Your browser isn't hit. Upgrade man!");
            }
            }
            function doTheGeoThang2() {
                if (Modernizr.geolocation){
                    navigator.geolocation.getCurrentPosition(
                function(position) {
                   loc2(position.coords.latitude,position.coords.longitude);
                }
            );
            }
            else {
                alert ("Your browser isn't hit. Upgrade man!");
                }
            }
    </script>
    
    <apex:form >
                <apex:actionRegion >
                    <center><apex:commandButton value="Punch In" onclick="doTheGeoThang1();" rendered="{!renderbutton}" /></center>
                        <apex:actionFunction name="loc1" action="{!PunchIn}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
                   <apex:outputPanel id="jsvalues"></apex:outputPanel>
                </apex:actionRegion>
                <apex:actionRegion >
                        <center><apex:commandButton value="Punch out" onclick="doTheGeoThang2();" rendered="{!render_pout}" /></center>
                        <apex:actionFunction name="loc2" action="{!PunchOut}" rerender="jsvaluespanel">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
                    <apex:outputPanel id="jsvaluespanel"></apex:outputPanel>
                </apex:actionRegion>
                <br/><b>Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Name}"/>
                <br/><br/><b>Account &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Account__c}"/>
                <br/><br/><b>Total Project Time &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Total_Project_Time__c}"/>
                <br/><br/><b>Client &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Client_Rate__c}"/> <br/> <br/>
              
    </apex:form>
            </div>
            </div>
            </div>
            </div>
        <center><apex:relatedList list="Project_time__r" title="Times" /> </center>

        </body>
    </html>
</apex:page>

controller:
 
public class ProjectTime_Controller {
      Apexpages.StandardController controller;
      public Project__c myCustomObject;
      public boolean renderbutton{get;set;}
      public boolean render_pout{get;set;}
 
      public ProjectTime_Controller (ApexPages.StandardController sc) {
          this.controller = sc;
          myCustomObject = (Project__c) sc.getRecord();   
          Id pageid = controller.getId();

          list<Project_Time__c> results = [select Name,id,Active__c  From Project_Time__c WHERE Active__c = True AND Project__c =:pageid AND Owner.id = :UserInfo.getUserId() Limit 1];

//count of active times
          Integer num = [select count() From Project_Time__c WHERE Active__c = True AND Project__c =:pageid AND Owner.id = :UserInfo.getUserId() Limit 1];
          if(num<1)
          {
              renderbutton=true;
              render_pout=false;
          }
          else
          {
              renderbutton=false;
              render_pout=true;
          }
          System.Debug(renderbutton);
       }

    public double valueLong { get; set; }
    public double valueLat { get; set; }
 
//Action functionality for PunchIn CommandButton
        public pagereference PunchIn() {
        Id pageid = controller.getId();
    
        Integer PunchCount = [select count() From Project_Time__c WHERE Active__c = True AND Project__c =:pageid Limit 1];
        Project_Time__c obj = new Project_Time__c();
    
        obj.Project__c = pageid;
        obj.Latitude__c = valuelat;
        obj.Longitude__c = valuelong;
        obj.Punch_In_Time__c=System.NOW();
        insert obj;
        PageReference reference=new PageReference('http://www.google.com');
        reference.setRedirect(true);

        return reference;
        }
        
//Action functionality for PunchOut CommandButton
    public pagereference PunchOut() {
        Id pageid = controller.getId();
        Project_Time__c obj2 = new Project_Time__c();
        Project_Time__c results = [select Name,id,Active__c  From Project_Time__c WHERE Active__c = True AND Project__c =:pageid Limit 1];
      
        obj2.ID = ((ID)results.get('id'));
    
        obj2.Punch_Out_Latitude__c= valuelat;
        obj2.Punch_Out_Longitude__c= valuelong;
        obj2.Punch_Out_Time__c=System.NOW();
        update obj2;

//Counts Total hours of the project
        project__c objproject = new project__c();
        AggregateResult TotalHours = [select project__c  ,sum(Total_Time__c)sumofhours FROM project_time__c Where Active__c = false group by project__c  having project__c = :pageid ];
        objproject.id=((ID)TotalHours.get('project__c'));
        objproject.Total_Project_Time__c=((decimal)TotalHours.get('sumofhours'));
        
        Update objproject;
        Pagereference ref = new Pagereference('/apex/Pool_PH_WaterQuality');
        ref.setRedirect(true);
        return ref;
    }
}

 
hey,

i am having problem calling the fuction from controller and script using actionfunction. if i am using command button without actionfunction, everything is working fine. but with actionfuction nothing is getting executed . 
Code
<apex:page standardController="Project_Time__c" extensions="SwitchProject_Controller">
     <apex:includeScript value="{!$Resource.modernizr}"/>
   
    <script>
        function doTheGeoThang()
            {
            if (Modernizr.geolocation){
                navigator.geolocation.getCurrentPosition(
                function(position) {
                    loc(position.coords.latitude,position.coords.longitude);
                }
                );
            }
            else 
            {
                alert ("Your browser isn't hit. Upgrade man!");
            }
            }
    </script>
<apex:form >
<apex:pageblock >
<apex:pageBlockSection title="Switch Project" columns="1">
<apex:actionregion >
<apex:commandButton onclick="doTheGeoThang();" value="Switch Project"/><br/>
                        <apex:actionFunction name="loc" action="{!SwitchProject}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
</apex:actionregion>
<apex:inputField value="{!Project_Time__c.Project__c}" />

</apex:pageBlockSection>
 

</apex:pageblock>
</apex:form>
</apex:page>

thanks
Hello,

           We are using mytimestation.com to track time and attendence . we want to fetch all that data in salesforce automatically. How can it be done? Can it be done with api ?

Thanks for your time
Help me out with testing this class :
public PageReference Next_FoundationWalls(){
         if(myDoc.body != null){
         myDoc.parentId = myCustomObject.Id;
         myDoc.Name='FoundationWalls';
         insert myDoc;
         myDoc.body=null;}
         pageid=ApexPages.currentPage().getParameters().get('id');
         obj.Id=pageid;
         obj.Basement_Foundation_Walls__c = FoundationWalls;
         obj.Foundation_Wall_Notes__c=FoundationWallsNotes;
         update obj;
         Pagereference ref = new Pagereference('/apex/Floor_drain?id='+pageid);
         ref.setRedirect(true);
         return ref;
         }

mydoc is attachment type.

i tried this
@isTest
public class HomeEvaluation_Test {
    static testMethod void HomeEvaluationtest()
    {
        HomeEvaluation__c HE = new HomeEvaluation__c();
        HomeEvaluationController HC = new HomeEvaluationController(new ApexPages.StandardController(new HomeEvaluation__c()));
        String pageid;
        HE.id= pageid;
        HC.getItems();
        HC.getYesOrNO();
        HC.getDucting();
        PageReference pageRef = new Pagereference(''/apex/Floor_drain?id='+pageid);
        Test.setCurrentPage(pageRef);        
    }
}

it isnt coverining pagerefrence. 
Controller is much big, but i know how to cover other things. 
Thank you

I have created bootstrap page in which i have used lookup field. but i dont see lookup button when standardstylesheetis off. it only shows when value of standardstylesheet is "ON". i want to keep that off. is there any other way i can do that? i have created this page on custom object.
 

Thanks for your time

i am using excel connector to fetch product2 from production. i am only able to fetch the record which are created within past few days. i am having same issue with sandbox.  i am using table query wizard to fetch the data. 
If i am loading with apex data loader everything is working fine.  what could be the problem?

Thank you,
Nikunj vadi
i am a noob in product catalog, i want to add product , with price depending on area range . For Example ;
If area is 0-1000 than price is 50
if area is 1001-2000 than price is 100
so goes on .. it is uptop 40000.

is there an easy way to do this or i have to do it by some workflow or trigger only?
This is my code, i want to display account name of opportunity in my bootstrap page. i dont know why i am getting this error:

Error: Invalid field 'Opportunity.Contract' specified. Ensure that you use the full API name for any custom fields.
 
<!-- Visualforce Remote object coponent -->
<apex:remoteObjects >
<apex:remoteObjectModel name="Opportunity" jsShorthand="cont" fields="Name,Probability,CloseDate,Id,StageName,Contract">
</apex:remoteObjectModel>
</apex:remoteObjects>

thank you for your time.
First_Visit__c parent object , time__c child object, times__r relationship name

i am getting error: Invalid field hours__c for SObject First_Visit__c

Code
if(Trigger.isUpdate)
        {
          	Map<Id,First_Visit__c> childrenToUpdate = new Map<Id,First_Visit__c>();
			for(First_Visit__c parent : [Select Id,(Select Id,Hours__c From Times__r) From First_Visit__c Where Id in :trigger.newMap.keySet()]){
  	        for(First_Visit__c child : parent.Times__r){
           // Could use a list, but Map ensures that we wont have duplicate records.
          	  childrenToUpdate.put(child.Id,child);
  		      child.hours__c = parent.Time_Taken__c ;
        
    }

 
time__C is child object and account is parent object , i want to add hour__c field of time__c . 
i am activating trigger when any time record is created.
but i am getting error executing this query
Time__c tl = [select Time_Account_Mapping__c from Time__c order by LastModifiedById desc limit 1];
	
    Integer x = [select sum(Hours__c) From Time__c where Time_Account_Mapping__c in  (select Time_Account_Mapping__c from Time__c order by LastModifiedById desc limit 1)];


Error : expecting a right parentheses, found 'order'
i need total time consumed for one customer , here account if parent object and time is child object. now there are multiple child record. child record have time_taken__c field .  i want to create a trigger that add all the time record data. .
First_visit__c is parent record
Time__c child record

Here i am creating new record if first_visit__c is created.

i am able to insert the record,  but i need help to update it. I know this can be done by workflow rule but i would like to do it with trigger.
//Generate New Time Child Record when first Visit record is created
trigger Time_FirstVisit on First_Visit__c (after insert) 
	{
		Time__c ts= new Time__c();
//fvlast holds the value of last created firstvisit record
        First_Visit__c fvlast = [select Id from First_Visit__c order by CreatedDate desc limit 1];
        
        for(First_Visit__c fv:trigger.new)
        {
         ts.Purpose_of_Visit__c='First Visit';
         ts.Time_Account_Mapping__c= fv.Account_First_Visit_Mapping__c;
         ts.Hours__c=fv.Time_Taken__c;
         ts.Task_Date__c=Date.today();
         ts.First_Visit_Time_Mapping__c=fvlast.id;
        }
//insert new time record
        insert ts;
	}

i also tried this way but havnt tested but it should work: 
//Generate New Time Child Record when first Visit record is created
trigger Time_FirstVisit on First_Visit__c (after insert,after update) 
	{
        if(Trigger.isInsert)
        {
         	List<Time__c> tl = new List <Time__c>();
            for(First_Visit__c fv:trigger.new)
            {
                 if(fv.Time_Taken__c != null)
                 {
                     tl.add(new Time__c(Purpose_of_Visit__c='First Visit',
                     Time_Account_Mapping__c= fv.Account_First_Visit_Mapping__c,
                     Hours__c=fv.Time_Taken__c, 
                     Task_Date__c=Date.today(),
                     First_Visit_Time_Mapping__c=fv.id));
                 }
                  
        	}
        }
        if(Trigger.isUpdate)
        {
            for 
//         	    First_Visit__c FVL = [SELECT ID FROM First_Visit__c order by LastModifiedDate desc LIMIT 1];
//            	First_Visit__c childTL = [SELECT (Select ID from times__r) from first_visit__c Limit 1];
        }
    }

 

I want to build a form in which title of next page and name of record should increment by one. i dont know how to save the value in the controller because every time we direct to new vf page. controller value are getting null .

Example to explain situation:

Page1 :
some detail
Button1: Next          Button2: add another house

If you click on Next it redirects to new page and its value should be 1 which is not a problem
IF you click on add another house the next page title should be house 2 and name of record should be house2  and it direct to same page to create new record.


If he clicks again than it should go to house 3 . 
And if he click to next it redirect to another form which starts from 1. 

Can anyone help me how should i approch this ?            

Thanks

I Am creating Child record(Home_Model__c) of account object  Using this controller:

public class HomeModelController {
    Apexpages.StandardController controller;
    public Home_Model__c myCustomObject;
    public HomeModelController(ApexPages.StandardController sc)
    { 
    this.controller = sc;
    myCustomObject = (Home_Model__c) sc.getRecord();  
    }

// Create New record and Redirect  //Start Button Functionality  
    public PageReference New_HomeModel()
    {
          PageReference ret = controller.save();        
          Id pageid = controller.getId();
          Pagereference ref = new Pagereference('/apex/HM_Entrance);
          ref.setRedirect(true);
          return ref;
    }
}

Now Have another child object of Home Model Page. Entrance__C. Now I am having error becuase controller are diffrent :
"System.TypeException: Invalid conversion from runtime type SOBJECT:Entrance__c to SOBJECT:Home_Model__c "  
I want to use the created Home_model__c record id as a parent id of child record of Entrance .

I am not able to know how to approch this. How can i pass the id from one page to another ? 


 
Hey,

I am updating value of Max_Health_and_comfort__c in 1st vf page. Now i want to add some value on the same field in the next vf page. But i am getting null value from the field so i am not able to do addition .

I am using taking pageid from the url , creating object of the custom object obj and than trying to do addition,

HomeEvaluation__c obj = new HomeEvaluation__c();
Id pageid=ApexPages.currentPage().getParameters().get('id');
obj.Id=pageid;
MaxHealth = Maxvalue + obj.Max_Health_and_comfort__c;

On the 4th line i am getting error because i am getting null value in Max_Health_and_comfort__c, eventhough there is some value in the record. 
I am getting null value in my object but dont know why .

mail class:

public class ReportVariables{
        HomeEvaluation__c obj = new HomeEvaluation__c();     
        public Decimal MaxHealth =0 ;
       

        public Decimal Healthandcomfort(Integer Hea,Integer Maxvalue,Decimal CurrentMax){
        Id pageid=ApexPages.currentPage().getParameters().get('id');
        obj.Id=pageid;
      
 If(Hea==0)
        {
       
        MaxHealth = obj.Max_Health_and_comfort__c;
        obj.Max_Health_and_comfort__c= MaxHealth;
        update obj;
        return MaxHealth;
        }
        else{
        MaxHealth = Maxvalue + obj.Max_Health_and_comfort__c ;
        obj.Max_Health_and_comfort__c = MaxHealth;
        update obj;
        return MaxHealth;
       
        }

       }


Calling this class on pagereference but i am getting null value eventhough i am assiging some value before calling the class. 
page reference
pageid=ApexPages.currentPage().getParameters().get('id');
         obj.Id=pageid;
         obj.Ventilation_Ducting__c = Ducting;
         obj.Ducting_Notes__c=DuctingNotes;
         obj.Max_Health_and_comfort__c=0;
         update obj;
         Repobj.Healthandcomfort(Ducting,6,0);
         DuctingReportvalue = 2 * Ducting;

On the second page reference i need to used old value saved in the record. getting same error that time also.:

pageid=ApexPages.currentPage().getParameters().get('id');
         obj.Id=pageid;
         obj.Ventilation_Filters_Photo_air_condit__c = Filters;
         obj.Filter_Notes__c=FilterNotes;
         update obj;
         FilterMax = obj.Max_Health_and_comfort__c;
         Repobj.Healthandcomfort(Filters,9,FilterMax);
         FiltersReportvalue = 3 * Filters;


please help me out 
Hey , i am creating mutiple record at once in my custom object. but that object is child object of  FirstVisit(custom object). Here i am not able to insert the record as child record becasue it is not getting parent id when i insert the record. I modified below code to work with my object , but can any one help me how can i give parent id when i am inserting. I know its easy but i am newbie.
public class ManageListController
{
public List<AccountWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
private Integer nextIdent=0;
 
public ManageListController()
{
  wrappers=new List<AccountWrapper>();
  for (Integer idx=0; idx<5; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
}
 
public void delWrapper()
{
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
  
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
}
 
public void addRows()
{
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
}
 
public PageReference save()
{
  List<Account> accs=new List<Account>();
  for (AccountWrapper wrap : wrappers)
  {
   accs.add(wrap.acc);
  }
  
  insert accs;
  
  return new PageReference('/' + Schema.getGlobalDescribe().get('Account').getDescribe().getKeyPrefix() + '/o');
}
 
public class AccountWrapper
{
  public Account acc {get; private set;}
  public Integer ident {get; private set;}
  
  public AccountWrapper(Integer inIdent)
  {
   ident=inIdent;
   acc=new Account(Name='Bulk Acc ' + ident);
  }
}
}

Thanks
I want to create a vf page in which a new input text field will be generated if you click last field and save it in record. Something like this:
http://jsfiddle.net/jCMc8/8/

Even it is ok if there is a button on clicking it it will create new field. Can anyone help me with that?
Thanks
i want to assigned a constant value for the field stored in a string . But i am getting an error:Expression cannot be assigned 

What is wrong with :
refOpportunityItem.get(Tierfield) = -1;
Opportunityitem__c refOpportunityItem = new refOpportunityItem();

   public void tierNumbers()
    {
        if(refOpportunityItem.Number_Of_Tier__c != Null)
        {
            NumberOftier=Integer.valueOf(refOpportunityItem.Number_Of_Tier__c);
            TierField ='Upper_Quantity_Tier_2__c';
            refOpportunityItem.Upper_Quantity_Tier_2__c = -1;
------In the next row i am getting error
            refOpportunityItem.get(Tierfield) = 1;
            //refOpportunityItem.get(Tierfield);
       }
{

 
hey,

In my code when i click on command button, data is getting inserted and updated, but page isn't getting redirected after click.  
please help me out here:
code:

vf page:
<apex:page standardController="Project__c" sidebar="false" showHeader="false" extensions="ProjectTime_Controller" id="TimeTrack" standardStylesheets="true" docType="html-5.0">
    <html lang="en">
        <head>
            <meta charset="utf-8" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
            <meta name="viewport" content="width=device-width, initial-scale=1"/>
            <meta name="description" content=""/>
            <meta name="author" content=""/>
    
            <title>Time Station</title>
    
            <!-- Bootstrap core CSS -->
            <apex:stylesheet value="{!URLFOR($Resource.Bootstrap3_3_2, '/bootstrap-3.3.2-dist/css/bootstrap.min.css')}" />
            <!-- Bootstrap theme -->
            <apex:stylesheet value="{!URLFOR($Resource.Bootstrap3_3_2, '/bootstrap-3.3.2-dist/css/bootstrap-theme.min.css')}" />
        </head>

        <body role="document">
            <div class="panel panel-default">
            <div class="panel-body">  
            <div class="well">
                <p>Bonjour {!$User.FirstName} {!$User.LastName}</p>
            </div>
            <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">Time Station</h3>
            </div>
            <div class="panel-body">
            
            

    <apex:includeScript value="{!$Resource.modernizr}"/>
    
    <script>
        function doTheGeoThang1()
            {
            if (Modernizr.geolocation){
                navigator.geolocation.getCurrentPosition(
                function(position) {
                    loc1(position.coords.latitude,position.coords.longitude);
                }
                );
            }
            else 
            {
                alert ("Your browser isn't hit. Upgrade man!");
            }
            }
            function doTheGeoThang2() {
                if (Modernizr.geolocation){
                    navigator.geolocation.getCurrentPosition(
                function(position) {
                   loc2(position.coords.latitude,position.coords.longitude);
                }
            );
            }
            else {
                alert ("Your browser isn't hit. Upgrade man!");
                }
            }
    </script>
    
    <apex:form >
                <apex:actionRegion >
                    <center><apex:commandButton value="Punch In" onclick="doTheGeoThang1();" rendered="{!renderbutton}" /></center>
                        <apex:actionFunction name="loc1" action="{!PunchIn}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
                   <apex:outputPanel id="jsvalues"></apex:outputPanel>
                </apex:actionRegion>
                <apex:actionRegion >
                        <center><apex:commandButton value="Punch out" onclick="doTheGeoThang2();" rendered="{!render_pout}" /></center>
                        <apex:actionFunction name="loc2" action="{!PunchOut}" rerender="jsvaluespanel">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
                    <apex:outputPanel id="jsvaluespanel"></apex:outputPanel>
                </apex:actionRegion>
                <br/><b>Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Name}"/>
                <br/><br/><b>Account &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Account__c}"/>
                <br/><br/><b>Total Project Time &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Total_Project_Time__c}"/>
                <br/><br/><b>Client &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><apex:outputField value="{!Project__c.Client_Rate__c}"/> <br/> <br/>
              
    </apex:form>
            </div>
            </div>
            </div>
            </div>
        <center><apex:relatedList list="Project_time__r" title="Times" /> </center>

        </body>
    </html>
</apex:page>

controller:
 
public class ProjectTime_Controller {
      Apexpages.StandardController controller;
      public Project__c myCustomObject;
      public boolean renderbutton{get;set;}
      public boolean render_pout{get;set;}
 
      public ProjectTime_Controller (ApexPages.StandardController sc) {
          this.controller = sc;
          myCustomObject = (Project__c) sc.getRecord();   
          Id pageid = controller.getId();

          list<Project_Time__c> results = [select Name,id,Active__c  From Project_Time__c WHERE Active__c = True AND Project__c =:pageid AND Owner.id = :UserInfo.getUserId() Limit 1];

//count of active times
          Integer num = [select count() From Project_Time__c WHERE Active__c = True AND Project__c =:pageid AND Owner.id = :UserInfo.getUserId() Limit 1];
          if(num<1)
          {
              renderbutton=true;
              render_pout=false;
          }
          else
          {
              renderbutton=false;
              render_pout=true;
          }
          System.Debug(renderbutton);
       }

    public double valueLong { get; set; }
    public double valueLat { get; set; }
 
//Action functionality for PunchIn CommandButton
        public pagereference PunchIn() {
        Id pageid = controller.getId();
    
        Integer PunchCount = [select count() From Project_Time__c WHERE Active__c = True AND Project__c =:pageid Limit 1];
        Project_Time__c obj = new Project_Time__c();
    
        obj.Project__c = pageid;
        obj.Latitude__c = valuelat;
        obj.Longitude__c = valuelong;
        obj.Punch_In_Time__c=System.NOW();
        insert obj;
        PageReference reference=new PageReference('http://www.google.com');
        reference.setRedirect(true);

        return reference;
        }
        
//Action functionality for PunchOut CommandButton
    public pagereference PunchOut() {
        Id pageid = controller.getId();
        Project_Time__c obj2 = new Project_Time__c();
        Project_Time__c results = [select Name,id,Active__c  From Project_Time__c WHERE Active__c = True AND Project__c =:pageid Limit 1];
      
        obj2.ID = ((ID)results.get('id'));
    
        obj2.Punch_Out_Latitude__c= valuelat;
        obj2.Punch_Out_Longitude__c= valuelong;
        obj2.Punch_Out_Time__c=System.NOW();
        update obj2;

//Counts Total hours of the project
        project__c objproject = new project__c();
        AggregateResult TotalHours = [select project__c  ,sum(Total_Time__c)sumofhours FROM project_time__c Where Active__c = false group by project__c  having project__c = :pageid ];
        objproject.id=((ID)TotalHours.get('project__c'));
        objproject.Total_Project_Time__c=((decimal)TotalHours.get('sumofhours'));
        
        Update objproject;
        Pagereference ref = new Pagereference('/apex/Pool_PH_WaterQuality');
        ref.setRedirect(true);
        return ref;
    }
}

 
hey,

i am having problem calling the fuction from controller and script using actionfunction. if i am using command button without actionfunction, everything is working fine. but with actionfuction nothing is getting executed . 
Code
<apex:page standardController="Project_Time__c" extensions="SwitchProject_Controller">
     <apex:includeScript value="{!$Resource.modernizr}"/>
   
    <script>
        function doTheGeoThang()
            {
            if (Modernizr.geolocation){
                navigator.geolocation.getCurrentPosition(
                function(position) {
                    loc(position.coords.latitude,position.coords.longitude);
                }
                );
            }
            else 
            {
                alert ("Your browser isn't hit. Upgrade man!");
            }
            }
    </script>
<apex:form >
<apex:pageblock >
<apex:pageBlockSection title="Switch Project" columns="1">
<apex:actionregion >
<apex:commandButton onclick="doTheGeoThang();" value="Switch Project"/><br/>
                        <apex:actionFunction name="loc" action="{!SwitchProject}" rerender="jsvalues">
                        <apex:param name="lat" value="" assignTo="{!valueLat}"/>
                        <apex:param name="long" value="" assignTo="{!valueLong}"/>
                        </apex:actionFunction>
</apex:actionregion>
<apex:inputField value="{!Project_Time__c.Project__c}" />

</apex:pageBlockSection>
 

</apex:pageblock>
</apex:form>
</apex:page>

thanks
Hi all,

I want to overide the delete button from the contact object. when i click del . it will appear different message ? Can anyone help me to handle it ?
 I want to count the number of opportunities for a particular date.
Scenario: how to display the records owned by a specific user when having multiple records owned by multiple users in the list view?
if possible, can we achieve it through UI or do we have to go for coding? any ideas or answers will be highly appreciated
We currently import data to a field, overwriting old data each time. We'd like to begin importing data to that field and keeping the previous data as well. How can we do this?

My thoughts:
Instead of overwriting field values each import, is there a way to append to the current value? Ex. FIELD1: oldvalue1, newervalue1, importedtodayvalue1

Maybe it's necessary to import to a picklist and create a workflow rule to prepend new data to a field in a list similar to above? How would we go about doing this? We'd like all data to be searchable.

Thanks so much for any help!
Help me out with testing this class :
public PageReference Next_FoundationWalls(){
         if(myDoc.body != null){
         myDoc.parentId = myCustomObject.Id;
         myDoc.Name='FoundationWalls';
         insert myDoc;
         myDoc.body=null;}
         pageid=ApexPages.currentPage().getParameters().get('id');
         obj.Id=pageid;
         obj.Basement_Foundation_Walls__c = FoundationWalls;
         obj.Foundation_Wall_Notes__c=FoundationWallsNotes;
         update obj;
         Pagereference ref = new Pagereference('/apex/Floor_drain?id='+pageid);
         ref.setRedirect(true);
         return ref;
         }

mydoc is attachment type.

i tried this
@isTest
public class HomeEvaluation_Test {
    static testMethod void HomeEvaluationtest()
    {
        HomeEvaluation__c HE = new HomeEvaluation__c();
        HomeEvaluationController HC = new HomeEvaluationController(new ApexPages.StandardController(new HomeEvaluation__c()));
        String pageid;
        HE.id= pageid;
        HC.getItems();
        HC.getYesOrNO();
        HC.getDucting();
        PageReference pageRef = new Pagereference(''/apex/Floor_drain?id='+pageid);
        Test.setCurrentPage(pageRef);        
    }
}

it isnt coverining pagerefrence. 
Controller is much big, but i know how to cover other things. 
Thank you

I have created bootstrap page in which i have used lookup field. but i dont see lookup button when standardstylesheetis off. it only shows when value of standardstylesheet is "ON". i want to keep that off. is there any other way i can do that? i have created this page on custom object.
 

Thanks for your time

I have a custom object with a lookup field (to another custom object) called Listing and a formula field that returns text.  

I thought that both of these were searchable fields, but they do not appear to be.  Is that correct?
i am trying to fetch fields from a aggregteresult but it is giving me error :Invalid field Time_Account_Mapping__c for SObject AggregateResult
 
Time__c tes = [select Time_Account_Mapping__c from Time__c order by LastModifiedById desc limit 1];
     
        AggregateResult obj = [Select Time_Account_Mapping__c,sum(Hours__c) from time__c group by Time_Account_Mapping__c having Time_Account_Mapping__c in (:tes.Time_Account_Mapping__c)];

	Account ppla = new Account();
        ppla.id = obj.Time_Account_Mapping__c;
        ppla.Total_Client_Hour__c=obj.sum(Hours__c);
    //    ppla.Total_Client_Hour__c = test.Unknown_Field__1;
        update ppla;
Help me out here.
Thanks
First_Visit__c parent object , time__c child object, times__r relationship name

i am getting error: Invalid field hours__c for SObject First_Visit__c

Code
if(Trigger.isUpdate)
        {
          	Map<Id,First_Visit__c> childrenToUpdate = new Map<Id,First_Visit__c>();
			for(First_Visit__c parent : [Select Id,(Select Id,Hours__c From Times__r) From First_Visit__c Where Id in :trigger.newMap.keySet()]){
  	        for(First_Visit__c child : parent.Times__r){
           // Could use a list, but Map ensures that we wont have duplicate records.
          	  childrenToUpdate.put(child.Id,child);
  		      child.hours__c = parent.Time_Taken__c ;
        
    }

 
i need total time consumed for one customer , here account if parent object and time is child object. now there are multiple child record. child record have time_taken__c field .  i want to create a trigger that add all the time record data. .
First_visit__c is parent record
Time__c child record

Here i am creating new record if first_visit__c is created.

i am able to insert the record,  but i need help to update it. I know this can be done by workflow rule but i would like to do it with trigger.
//Generate New Time Child Record when first Visit record is created
trigger Time_FirstVisit on First_Visit__c (after insert) 
	{
		Time__c ts= new Time__c();
//fvlast holds the value of last created firstvisit record
        First_Visit__c fvlast = [select Id from First_Visit__c order by CreatedDate desc limit 1];
        
        for(First_Visit__c fv:trigger.new)
        {
         ts.Purpose_of_Visit__c='First Visit';
         ts.Time_Account_Mapping__c= fv.Account_First_Visit_Mapping__c;
         ts.Hours__c=fv.Time_Taken__c;
         ts.Task_Date__c=Date.today();
         ts.First_Visit_Time_Mapping__c=fvlast.id;
        }
//insert new time record
        insert ts;
	}

i also tried this way but havnt tested but it should work: 
//Generate New Time Child Record when first Visit record is created
trigger Time_FirstVisit on First_Visit__c (after insert,after update) 
	{
        if(Trigger.isInsert)
        {
         	List<Time__c> tl = new List <Time__c>();
            for(First_Visit__c fv:trigger.new)
            {
                 if(fv.Time_Taken__c != null)
                 {
                     tl.add(new Time__c(Purpose_of_Visit__c='First Visit',
                     Time_Account_Mapping__c= fv.Account_First_Visit_Mapping__c,
                     Hours__c=fv.Time_Taken__c, 
                     Task_Date__c=Date.today(),
                     First_Visit_Time_Mapping__c=fv.id));
                 }
                  
        	}
        }
        if(Trigger.isUpdate)
        {
            for 
//         	    First_Visit__c FVL = [SELECT ID FROM First_Visit__c order by LastModifiedDate desc LIMIT 1];
//            	First_Visit__c childTL = [SELECT (Select ID from times__r) from first_visit__c Limit 1];
        }
    }

 

I want to build a form in which title of next page and name of record should increment by one. i dont know how to save the value in the controller because every time we direct to new vf page. controller value are getting null .

Example to explain situation:

Page1 :
some detail
Button1: Next          Button2: add another house

If you click on Next it redirects to new page and its value should be 1 which is not a problem
IF you click on add another house the next page title should be house 2 and name of record should be house2  and it direct to same page to create new record.


If he clicks again than it should go to house 3 . 
And if he click to next it redirect to another form which starts from 1. 

Can anyone help me how should i approch this ?            

Thanks

All,
I have a table built for allocating expenses by company. Right now, all 7 rows are displaying. I would like to only display 2 rows, as a 50/50 allocation is the most likely. If the total doesn't equal 100% after the 1st two allocations, I would like another row to show up until the total equals 100%. Also, I would like a checkbox that allows for an automatic "split evenly". Here is my current code, any help with adding these requests for a better user experience would be great!

Current Screenshot:
User-added image

Controller:
public Boolean showCompany {get; set;}
    public Boolean showAllocation {get; set;}
    
    public List <Expense_Line_Items__c> companies {get; set;}
    
    public PageReference AllocationTable(){
        if(Expense_Line_Items__c.AllocationCheckbox__c = true){
            showCompany = true;
            showAllocation = true;
            companies = [Select Company__c, Allocation__c From Expense_Line_Items__c];
        }
        else if(Expense_Line_Items__c.AllocationCheckbox__c = false){
            return null;
        }
    }

VF:
<apex:pageBlockSectionItem >
                    <apex:outputLabel value="{!$ObjectType.Expense_Line_Items__c.Fields.AllocationCheckbox__c.Label}" />
                    <apex:outputPanel layout="block" styleClass="notrequiredInput">
                        <apex:inputCheckbox value="{!expenseLineItem.AllocationCheckbox__c}"/>
                        <apex:actionSupport event="onclick" rerender="pbExpenseLineItems"/>
                        </apex:outputPanel>
                </apex:pageBlockSectionItem> 
            </apex:pageBlockSection>
                
             <apex:pageBlockSection title="Allocate Expenses" Columns="1"  collapsible="false" rendered="{!(expenseLineItem.AllocationCheckbox__c == true)}">
                <apex:outputLabel value="Please choose the percentage of allocation to its corresponding company." />
                
                <apex:pageBlockTable var="company" columns="2" value="{!expenseLineItemContact}">
                    <table>
                        <apex:column headerValue="{!$ObjectType.Expense_Line_Items__c.Fields.Company__c.Label}" rendered="{!(expenseLineItem.AllocationCheckbox__c == true)}">
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                            <tr>
                                <td><apex:inputField value="{!expenseLineItem.Company__c}"/></td>
                                <td><apex:inputField value="{!expenseLineItem.Allocation__c}"/></td>
                            </tr>
                        </apex:column>
                    </table>
                    <table>
                        <apex:column headerValue="{!$ObjectType.Expense_Line_Items__c.Fields.Allocation__c.Label}" rendered="{!(expenseLineItem.AllocationCheckbox__c == true)}">
                        </apex:column>
                    </table>
                 </apex:pageBlockTable>
            </apex:pageBlockSection>

 
What different ways can we hard delete salesforce records.

1. From within Apex (batch) ?
2. Bulk API (Java) ? 
3. Data loader - Hard Delete options ? Tried this, working fine.

Out requirements is to have a batch running every X minutes (inside/outide of SF) which can query records and hard delete them.

-Sid
I am confused as to why a SOQL query against a custom object is only returning the first 150 rows when it should be returning up to the governor limit (50,000). Does anyone have any ideas why my query is being limited?

Here's my controller method:
@RemoteAction
public static List<Metro__c> getAllMetros(){
    String query = 'SELECT Id, Name, state__c FROM Metro__c ORDER BY Name';
    List<Metro__c> r = Database.query(query);
    System.debug('r='+r.size());
    return r;
}
When i look at the debug I see:
10:48:27:237 USER_DEBUG [54]|DEBUG|r=150

There are several thousand records in the Metro__c object. Any insight into this would be appreciated.
 
Hi,
how can i load data when click on particular tab.
I create visualforce (page) tab when i ckick tab but the page is not refresh (inside tab i use <apex:include p"></apex:include>).How can i do please giv me ur solution..
-----------------------------
Visualforce page:
<apex:page standardController="Case" showHeader="true" tabStyle="case" sidebar="false">

 <style>
    .activeTab {background-color: #B0E2FF; color:black; background-image:none }
    .inactiveTab { background-color: lightgrey; color:black; background-image:none}
 </style>
     <apex:tabPanel switchType="server" selectedTab="tabdetails" 
                  id="CaseTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
        <apex:tab label="Unclaimed Ticket" name="OpenActivities"  id="tabOpenAct">
        <apex:include pageName="UnclaimedTicketPage"/>
        </apex:tab>
        <apex:tab label="Claimed Ticket" name="OpenActivitiesg" id="claim_id"> 
        <apex:include pageName="ClaimedTicketPage"/>
        </apex:tab>
        <apex:tab label="Patient view" name="OpenActivities3" id="tabOpenAct126">
        <apex:include pageName="protectedSearch3"/>
        </apex:tab>
     </apex:tabPanel>
<script type="text/javascript" language="javascript">
    if(jQuery) {
        jQuery.noConflict();
    }
    var $jq = jQuery.noConflict();
    function testrun() {
    cler();
    }
    $jq(document).ready(function() {
    $jq('[id$=claim_id]').click(function() {

    //$jq('window').location.reload(true);
    $jq(document).location.reload();
    });
    });
</script>
</apex:page>
------------------------------------------
 
Here's an example of a section I'm replicating in Visualforce. I feel like I've travelled the Seven Kingdoms trying to find an answer to this question. Visualforce will evenly distribute the fields between two columns; however, the client would like it to replicate the native page layout, and that means certain fields exist in a certain order and in specific columns. I've tried Style attributes but they only seem to effect the formatting of the field itself and not which column to associate said field. 

<apex:pageBlockSection title="Special Request Tracking" columns="2" rendered="{!Case.Request_Type2__c== 'Special Requests'}">
                   <apex:inputField value="{!Case.Origin}"/>
                   <apex:inputField value="{!Case.ServicingData__c}"/>
                   <apex:inputField value="{!Case.Type_of_Communication__c}"/>
                   <apex:inputText value="{!Case.Contact}"/>
                   <apex:inputField value="{!Case.Requestor_Role__c}"/>
                   <apex:inputField value="{!Case.Exclude_from_CPI_Reporting__c}"/>
             </apex:pageBlockSection>

Any help would be greatly appreciated!
in 2015 latest release i dint see the option apex classs under develope option,where i get that option to write a apex class?
Hi.

In the VF I used the date format as YYYY-MM-dd in the 
<apex:outputText value="{0,date,YYYY/MM/dd}">
Before the last week of the year it was OK. When the new year falls in the  last week of Decemeber comes the issue.
For example
2014:
S   M  T  W Th F Sat
28 29 30 31 1   2 3

In the above calendar 1st Jan of 2015 falls in the Thurusday.So when I viewd the records of 28,29,30 of December 2014 It showed as
2015-12-28
2015-12-29
2015-12-30
2015-12-31

After that I came to know that
@"YYYY" is week-based calendar year.
@"yyyy" is ordinary calendar year.
http://realmacsoftware.com/blog/working-with-date-and-time

cheers
suresh