• Nikunj V
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
Hey,

       I have created vf page , code is given below. page is working fine with the permission , but i need to give autor apex permission otherwise it isn't working. i cant give that to every profile and if i disable it than the page stops working. here is the code , what should i do?
 
<apex:page standardController="Project__c" sidebar="false" showHeader="false" extensions="ProjectTime_Controller" id="TimeTrack" standardStylesheets="false" 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="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">Time Station</h3>
            </div>
            <div class="panel-body">

        <script>
            var pos = {};
            function success(position) {
              pos = position.coords;
              console.log(pos);
            }
            
            function error(msg) {
             console.log(msg);
            }
            
            if (navigator.geolocation) {
              navigator.geolocation.getCurrentPosition(success, error);
            } else {
              error('not supported');
            }
            
            function setPos() {
                var inputs = document.getElementsByTagName('input');
                for(var x = 0; x < inputs.length; x++) {
                    if(inputs[x].id.indexOf('contactlat') >= 0) { inputs[x].value = pos.latitude; }
                    if(inputs[x].id.indexOf('contactlong') >= 0) { inputs[x].value = pos.longitude; }
                }
            }
                        
             if('{!showMessage}'=='True'){
                 alert('You Are not Logged In any project, so you can not switch project, please select a project and Punch In to log time');
             }
            
        </script>
        
        <apex:form >
        <apex:pageBlock rendered="{!AcitivityStatus}">
        <div class="alert alert-info">
        <center><b>Your Are Currently Logged in "{!sObjName}" </b></center>
        </div>
       
        </apex:pageBlock>
            <center><apex:commandButton action="{!Back}" value="Select Project To Log Time" rendered="{!disablepro}" styleClass="btn btn-lg btn-primary" /></center> <!--style="height:45px;width:230px;font-size:15px;" -->
            <center><apex:commandButton action="{!P_Out_Main}" value="Punch Out" onclick="setPos();" rendered="{!AcitivityStatus}" styleClass="btn btn-lg btn-primary"/></center><br/><br/> <!--style="height:40px;width:180px;font-size:15px;"-->
            <center><apex:commandButton action="{!actionDo}" value="Switch Project" rendered="{!AcitivityStatus}" styleClass="btn btn-lg btn-primary"/></center>
            <apex:inputhidden value="{!valuelat}" id="contactlat"/> 
            <apex:inputhidden value="{!valuelong}" id="contactlong" />
         </apex:form>
     </div>
     </div>
     </div>
     </div>
     </body>
     </html>
</apex:page>

 
I am redirecting to tab on button click. That is working find on desktop version. but when i use it on mobile , it is opening new window in google chrome and displays nothing .
Here is my code :
 
public pagereference Back() {
        Schema.DescribeSObjectResult anySObjectSchema = Project__c.SObjectType.getDescribe();
        String objectIdPrefix = anySObjectSchema.getKeyPrefix();
        PageReference ref = new PageReference('/'+objectIdPrefix);
        ref.setRedirect(true);
        return ref;
    }


And i am also showing alert box on some codition. it is working find in salesforce desktop but no alerts are shown on salesforce1.


Thanks for the help

 
hey,


i am trying to insert an object on button click and than need to redirect the page. with this code i am not able to redirect page. and also sometime it is inserting data, sometime not. i dont know why. please help me out:
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 ref = new Pagereference('/apex/Pool_PH_WaterQuality');
             ref.setRedirect(true);
             return ref;
        }

 
hey,

In this vf page commandbutton isnt getting executed. i am not able to figure out the problem. without actionfunction if i call function directly from controller , it is working . 

     
   
    






 
hello,


commandbutton with action function isn't working for punch in on line 32, but same kind of functionality is working on line 43. can anyone point out what is wrong?
<apex:page standardController="Project__c" sidebar="false" showHeader="true" extensions="ProjectTime_Controller">

<apex:includeScript value="{!$Resource.modernizr}"/>

<script>
function doTheGeoThang() {
if (Modernizr.geolocation){
navigator.geolocation.getCurrentPosition(
function(position) {
findMe2(position.coords.latitude,position.coords.longitude);
}
);
} else {
alert ("Your browser isn't hit. Upgrade man!");
}
}
function doTheGeoThang3() {
if (Modernizr.geolocation){
navigator.geolocation.getCurrentPosition(
function(position) {
findMe3(position.coords.latitude,position.coords.longitude);
}
);
} else {
alert ("Your browser isn't hit. Upgrade man!");
}
}
</script>

<apex:form >
<apex:pageBlock ><apex:pageblockSection >
<apex:commandButton value="Punch In" onclick="doTheGeoThang();"/><br/><br/>
<apex:actionFunction name="findMe2" action="{!PunchIn}" rerender="jsvalues">
<apex:param name="lat" value="" assignTo="{!valueLat}"/>
<apex:param name="long" value="" assignTo="{!valueLong}"/>
</apex:actionFunction></apex:pageblockSection>
</apex:pageBlock></apex:form>


<apex:form ><apex:actionRegion >
<b><span style="cursor: pointer;"
onclick="doTheGeoThang3()">
<center>Punch Out</center>
</span>


</b><br/><br/>
<apex:actionFunction name="findMe3" action="{!PunchOut}" rerender="jsvalues">
<apex:param name="lat" value="" assignTo="{!valueLat}"/>
<apex:param name="long" value="" assignTo="{!valueLong}"/>
</apex:actionFunction></apex:actionRegion>
</apex:form>
</apex:page>

 
Hey,
I am using apex:action 2 times. it is calling wrong action function everytime.

Here is the code
 
<apex:page standardController="Project__c" sidebar="false" showHeader="true" extensions="test3">
<apex:includeScript value="{!$Resource.modernizr}"/>
<script>
function doTheGeoThang() {
if (Modernizr.geolocation){
navigator.geolocation.getCurrentPosition(
function(position) {
findMe(position.coords.latitude,position.coords.longitude);
}
);
} else {
alert ("Your browser isn't hit. Upgrade man!");
}
}
</script>
<apex:form >
<apex:pageBlock >

<apex:actionRegion ><b><span style="cursor: pointer;"
onclick="doTheGeoThang()">
<center>Punch In</center>
</span>
</b><br/><br/>
<apex:actionFunction name="findMe" action="{!PunchIn}" rerender="jsvalues">
<apex:param name="lat" value="" assignTo="{!valueLat}"/>
<apex:param name="long" value="" assignTo="{!valueLong}"/>
</apex:actionFunction></apex:actionRegion>
</apex:pageBlock></apex:form>



<apex:form ><apex:actionRegion >
<b><span style="cursor: pointer;"
onclick="doTheGeoThang()">
<center>Punch Out</center>
</span>


</b><br/><br/>
<apex:actionFunction name="findMe" action="{!PunchOut}" rerender="jsvalues">
<apex:param name="lat" value="" assignTo="{!valueLat}"/>
<apex:param name="long" value="" assignTo="{!valueLong}"/>
</apex:actionFunction></apex:actionRegion>
</apex:form>


</apex:page>


here, when i click on punchin, it is calling punchout apex:actionfunction instead of punchin. i tried pageblock, apex:region , but everytime it is calling wrong method. please help me out here. 


Thanks
Hello,

i am learning bootstrap and need to see opportunity based on some condition in one bootstrap page. i have soql list, now how can i create html table. and is it possible to edit the same opportunity on the same bootstrap page?

thanks for your time :)
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
hey,


i am trying to insert an object on button click and than need to redirect the page. with this code i am not able to redirect page. and also sometime it is inserting data, sometime not. i dont know why. please help me out:
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 ref = new Pagereference('/apex/Pool_PH_WaterQuality');
             ref.setRedirect(true);
             return ref;
        }

 
hello,


commandbutton with action function isn't working for punch in on line 32, but same kind of functionality is working on line 43. can anyone point out what is wrong?
<apex:page standardController="Project__c" sidebar="false" showHeader="true" extensions="ProjectTime_Controller">

<apex:includeScript value="{!$Resource.modernizr}"/>

<script>
function doTheGeoThang() {
if (Modernizr.geolocation){
navigator.geolocation.getCurrentPosition(
function(position) {
findMe2(position.coords.latitude,position.coords.longitude);
}
);
} else {
alert ("Your browser isn't hit. Upgrade man!");
}
}
function doTheGeoThang3() {
if (Modernizr.geolocation){
navigator.geolocation.getCurrentPosition(
function(position) {
findMe3(position.coords.latitude,position.coords.longitude);
}
);
} else {
alert ("Your browser isn't hit. Upgrade man!");
}
}
</script>

<apex:form >
<apex:pageBlock ><apex:pageblockSection >
<apex:commandButton value="Punch In" onclick="doTheGeoThang();"/><br/><br/>
<apex:actionFunction name="findMe2" action="{!PunchIn}" rerender="jsvalues">
<apex:param name="lat" value="" assignTo="{!valueLat}"/>
<apex:param name="long" value="" assignTo="{!valueLong}"/>
</apex:actionFunction></apex:pageblockSection>
</apex:pageBlock></apex:form>


<apex:form ><apex:actionRegion >
<b><span style="cursor: pointer;"
onclick="doTheGeoThang3()">
<center>Punch Out</center>
</span>


</b><br/><br/>
<apex:actionFunction name="findMe3" action="{!PunchOut}" rerender="jsvalues">
<apex:param name="lat" value="" assignTo="{!valueLat}"/>
<apex:param name="long" value="" assignTo="{!valueLong}"/>
</apex:actionFunction></apex:actionRegion>
</apex:form>
</apex:page>

 
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