• bsil bsil
  • NEWBIE
  • 15 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 15
    Replies
how to filter login history records based on login time.

my requirments is for ex: assum that we have 100 records for one user. out of that 10 recordes data like the below.

loginType,application,sourceip,logindate is same.
but the time is different.
in case if we have time difference is less than 5 minutes then we have to avoid all and consider one reccord.

acctually i am inserting this login history in to some custom object:

see the blow code:
global class loginCopybatch implements Database.Batchable<sObject> {     
     
    global set<Newloginhistoryobject__c> loginHistoryList = new set<Newloginhistoryobject__c>();
    global list<Newloginhistoryobject__c> loginHistoryList1 = new list<Newloginhistoryobject__c>();
    global Map <Id,User> userList = new Map<Id, User>();
    global list<user> users = new list<user>();
    global String[] newLoginHistoryIds;
    // created map on feb,03,2015
    global map<id,list<loginhistory>> loginhistorymap;
    // ends
    
    global loginCopybatch()
    {
       // feb, 03, 2015 
       loginhistorymap = new map<id,list<loginhistory>>();
       //ends
       users = [SELECT ID, FIRSTNAME,LASTNAME,EMAIL,UserRole.Name,username FROM USER];
       for(user u : users)
       {
           userList.put(u.id, u);
       }
       List<Newloginhistoryobject__c> newLoginHistoryIdsList = [select LoginHistoryID_Ref__c from Newloginhistoryobject__c where logindate__c = LAST_N_DAYS:10];
       newLoginHistoryIds = new String[newLoginHistoryIdsList.size()];
       Integer i=0;
       try
       {
          for(Newloginhistoryobject__c loginHistoryId : newLoginHistoryIdsList)
          {
              newLoginHistoryIds[i++] = (String)(loginHistoryId.LoginHistoryID_Ref__c);
          }
       }
        catch(Exception e)
        {
            System.debug('Exception1');
            throw e;
        }
 
    }
    
    global list<loginhistory> start(Database.BatchableContext BC) 
    {  
    
        try
        {   
           // string str = '005K0000002SQsE';
            String query = 'select id,userid,status,SourceIp,logintime,application,logintype from loginhistory where logintime = LAST_N_DAYS:7 and id not in :newLoginHistoryIds order by logintime asc';
           // String query = 'select id,userid,status,SourceIp,logintime,application,logintype from loginhistory where logintime = today and id not in :newLoginHistoryIds and userid =:str order by logintime asc';
            return Database.Query(query);
        }
        catch(Exception e)
        {
            throw e;
        }
    }
   
    global void execute(Database.BatchableContext BC, List<loginhistory> scope) 
    {
         try
         {
             system.debug('*****Before Map'+loginhistorymap);
             for(loginhistory rec : scope)
             {
                    // feb, 03, 2015
                    if(rec.application != 'Salesforce for Outlook'){
                        if(!loginhistorymap.keySet().contains(rec.userid)){
                            loginhistorymap.put(rec.userid, new List <loginhistory> {rec});
                        }
                        else{
                            List<loginhistory> oldList = loginhistorymap.get(rec.userid);
                            oldList.add(rec);
                            loginhistorymap.put(rec.userid, oldList);
                        }
                    }                     
                           
            }
            // feb, 03, 2015
            //integre count = 0;
            system.debug('*****After Map'+loginhistorymap);
            List <loginhistory> lh ;                          
                for(Id id : loginhistorymap.keySet()){
                    lh = new List <loginhistory>();  
                    lh.addAll(loginhistorymap.get(id));
                    system.debug('111111111111111111:' +lh.size());
                    integer lhsize = lh.size()-1;
                    //
                    Newloginhistoryobject__c   newLoginHistory1 = new Newloginhistoryobject__c ();  
                            newLoginHistory1.SourceIp__c = lh[lhsize].sourceIp;
                            newLoginHistory1.First_Name__c = userList.get(lh[lhsize].userId).firstname;
                            newLoginHistory1.LastName__c = userList.get(lh[lhsize].userId).LastName;
                            newLoginHistory1.Email__c = userList.get(lh[lhsize].userId).email;
                            newLoginHistory1.loginapplication__c = lh[lhsize].application;
                            newLoginHistory1.logindatetime__c = lh[lhsize].logintime;
                            newLoginHistory1.logindate__c = (lh[lhsize].logintime).date();
                            newLoginHistory1.logintype__c = lh[lhsize].logintype;
                            newLoginHistory1.LoginHistoryID_Ref__c = lh[lhsize].id;
                            newLoginHistory1.loginstatus__c = lh[lhsize].Status;
                            newLoginHistory1.userid__c = lh[lhsize].UserId;
                            newLoginHistory1.UserRole__c = userList.get(lh[lhsize].userId).UserRole.name;
                            newLoginHistory1.User_Name__c = userList.get(lh[lhsize].userId).id;  
                            //System.debug(loginHistoryList);
                            loginHistoryList.add(newLoginHistory1);
                            //
                    for(integer i = 0;i<lh.size();i++){
                        for(integer j = i+1;j<lh.size();j++){
                        system.debug('*****LH'+lh[i]);
                        system.debug('*****LH +1'+lh[j]);                        
                        if(lh[i].application == lh[j].application && lh[i].logintype == lh[j].logintype && lh[i].SourceIp == lh[j].SourceIp ){
                                                system.debug('*****ALL ARE EQUAL'); 
                            if(lh[i].logintime.date() == lh[i+1].logintime.date()){
                                                system.debug('*****SAME DATE');                                                             
                                Long dt1Long = lh[i].logintime.getTime();
                                Long dt2Long = lh[j].logintime.getTime();
                                Long milliseconds = dt2Long - dt1Long;
                                Long seconds = milliseconds / 1000;
                                long minutes = seconds / 60; 
                                 system.debug('*****MINUTES'+minutes); 
                                if(minutes < 5){
                                                                 system.debug('*****MINUTES < 5'+minutes);
                                    Newloginhistoryobject__c   newLoginHistory = new Newloginhistoryobject__c (); 
                                    newLoginHistory.SourceIp__c = lh[j].sourceIp;
                                    newLoginHistory.First_Name__c = userList.get(lh[j].userId).firstname;
                                    newLoginHistory.LastName__c = userList.get(lh[j].userId).LastName;
                                    newLoginHistory.Email__c = userList.get(lh[j].userId).email;
                                    newLoginHistory.loginapplication__c = lh[j].application;
                                    newLoginHistory.logindatetime__c = lh[j].logintime;
                                    newLoginHistory.logindate__c = (lh[j].logintime).date();
                                    newLoginHistory.logintype__c = lh[j].logintype;
                                    newLoginHistory.LoginHistoryID_Ref__c = lh[j].id;
                                    newLoginHistory.loginstatus__c = lh[j].Status;
                                    newLoginHistory.userid__c = lh[j].UserId;
                                    newLoginHistory.UserRole__c = userList.get(lh[j].userId).UserRole.name;
                                    newLoginHistory.User_Name__c = userList.get(lh[j].userId).id;  
                                    //System.debug(loginHistoryList);
                                    loginHistoryList.add(newLoginHistory);
                                    lh.remove(i);
                                }
                                else{
                                                                 system.debug('*****MINUTES > 5'+minutes); 
                                    Newloginhistoryobject__c   newLoginHistory = new Newloginhistoryobject__c ();  
                                    newLoginHistory.SourceIp__c = lh[i].sourceIp;
                                    newLoginHistory.First_Name__c = userList.get(lh[i].userId).firstname;
                                    newLoginHistory.LastName__c = userList.get(lh[i].userId).LastName;
                                    newLoginHistory.Email__c = userList.get(lh[i].userId).email;
                                    newLoginHistory.loginapplication__c = lh[i].application;
                                    newLoginHistory.logindatetime__c = lh[i].logintime;
                                    newLoginHistory.logindate__c = (lh[i].logintime).date();
                                    newLoginHistory.logintype__c = lh[i].logintype;
                                    newLoginHistory.LoginHistoryID_Ref__c = lh[i].id;
                                    newLoginHistory.loginstatus__c = lh[i].Status;
                                    newLoginHistory.userid__c = lh[i].UserId;
                                    newLoginHistory.UserRole__c = userList.get(lh[i].userId).UserRole.name;
                                    newLoginHistory.User_Name__c = userList.get(lh[i].userId).id;  
                                    //System.debug(loginHistoryList);
                                    loginHistoryList.add(newLoginHistory);
                                    
                                }                               
                            }
                            else{
                            system.debug('*****ALL ARE NOT EQUAL');
                            Newloginhistoryobject__c   newLoginHistory = new Newloginhistoryobject__c ();  
                            newLoginHistory.SourceIp__c = lh[i].sourceIp;
                            newLoginHistory.First_Name__c = userList.get(lh[i].userId).firstname;
                            newLoginHistory.LastName__c = userList.get(lh[i].userId).LastName;
                            newLoginHistory.Email__c = userList.get(lh[i].userId).email;
                            newLoginHistory.loginapplication__c = lh[i].application;
                            newLoginHistory.logindatetime__c = lh[i].logintime;
                            newLoginHistory.logindate__c = (lh[i].logintime).date();
                            newLoginHistory.logintype__c = lh[i].logintype;
                            newLoginHistory.LoginHistoryID_Ref__c = lh[i].id;
                            newLoginHistory.loginstatus__c = lh[i].Status;
                            newLoginHistory.userid__c = lh[i].UserId;
                            newLoginHistory.UserRole__c = userList.get(lh[i].userId).UserRole.name;
                            newLoginHistory.User_Name__c = userList.get(lh[i].userId).id;  
                            //System.debug(loginHistoryList);
                            loginHistoryList.add(newLoginHistory);
                        }
                              
                        }
                        else{
                            system.debug('*****ALL ARE NOT EQUAL');
                            Newloginhistoryobject__c   newLoginHistory = new Newloginhistoryobject__c ();  
                            newLoginHistory.SourceIp__c = lh[i].sourceIp;
                            newLoginHistory.First_Name__c = userList.get(lh[i].userId).firstname;
                            newLoginHistory.LastName__c = userList.get(lh[i].userId).LastName;
                            newLoginHistory.Email__c = userList.get(lh[i].userId).email;
                            newLoginHistory.loginapplication__c = lh[i].application;
                            newLoginHistory.logindatetime__c = lh[i].logintime;
                            newLoginHistory.logindate__c = (lh[i].logintime).date();
                            newLoginHistory.logintype__c = lh[i].logintype;
                            newLoginHistory.LoginHistoryID_Ref__c = lh[i].id;
                            newLoginHistory.loginstatus__c = lh[i].Status;
                            newLoginHistory.userid__c = lh[i].UserId;
                            newLoginHistory.UserRole__c = userList.get(lh[i].userId).UserRole.name;
                            newLoginHistory.User_Name__c = userList.get(lh[i].userId).id;  
                            //System.debug(loginHistoryList);
                            loginHistoryList.add(newLoginHistory);
                        }
                        }//second for loop
                    }//first forloop
                  // lh.clear(); 
                } //main for loop
            //ends
        }
         catch(Exception e)
         {
         }
         if(loginHistoryList.size() != null)
         {
             loginHistoryList1.addAll(loginHistoryList);
             insert loginHistoryList1;             
         }
         
    }   
    
}


 
Hi Developers,

I got one requirment regarding calendar in salesforce.

I want functionaly like when i click on any date in salesforce standard calendar i want open pop up with visualforce page..

this functionaliy only in standard salesforce calendar not visualforce. just i want open visualforc as with new window from calendar.

If any body know please share with me.

Thanks in advance.
hi,

I am facing problem in sorting records in pageblock table see the blow code was working fine for sorting recordes based on column.
when i am going to filter the records based on listview it was not working
this is the code for filtering records based on listview
if(AccFilterId != null)
                {
                    AccSetController.setFilterId(AccFilterId);
                }
this i used in Standardsetcontroller in the apex class
if i will not use the above code for filetering it will work for sorting but it will not filter based on listview.
see the total visualforce and apex code below

Kindly suggest me how to fix this issue.
<apex:page controller="newProjectCreationController" sidebar="false" docType="html-5.0">
    
    <style type="text/css">
        .loadingIcon {
        background-image: url(/img/loading.gif);
        width: 16px;
        height: 16px;
        }
       
    </style>
    <script type="text/javascript">
     function doCheckboxChange(cb,itemId){
        //alert(itemId);    
        if(cb.checked==true){
            aSelectItem(itemId);
        }
        else{
            aDeselectItem(itemId);
        }
    }
    
    function checkAll(cb,cbid)
    {
        var inputElem = document.getElementsByTagName("input");
        for(var i=0; i<inputElem.length; i++)
        {
            
            if(inputElem[i].id.indexOf(cbid)!=-1){
                inputElem[i].checked = cb.checked;
            }
        }
    }
    </script>
    
    <apex:form id="pageForm">
        
        <apex:pageBlock id="block">
        
            <div align="left">
               <b> Views:  </b>
                <apex:selectList value="{!AccFilterId}" size="1" id="filterMenu">
                    <apex:selectOptions value="{!AccountExistingViews}"></apex:selectOptions>
                    <apex:actionSupport event="onchange"  action="{!resetFilter}" rerender="mpb" status="ajaxStatus"/>
                </apex:selectList>
                
                <apex:actionStatus id="ajaxStatus" startText="Loading..."  stopText=""/>
            </div> 
           
        </apex:pageBlock>
        <apex:pageBlock title="List Of Accounts" id="mpb">
            <apex:actionStatus startText=" (sorting...)" stopText=" (done)" id="TableUpdateStatus"/>
            <apex:actionFunction name="aSelectItem" action="{!doSelectItem}" rerender="table,count">
                <apex:param name="contextItem" value="" assignTo="{!contextItem}"/>
            </apex:actionFunction>
            <apex:actionFunction name="aDeselectItem" action="{!doDeselectItem}" rerender="table,count">
                <apex:param name="contextItem" value="" assignTo="{!contextItem}"/>
            </apex:actionFunction>
            <apex:pageBlockTable value="{!CurrentList}" var="c" id="table" >
                <apex:column >
                    <apex:facet name="header">
                        <apex:inputcheckbox value="{!fals}">
                        <apex:actionSupport event="onclick" onsubmit="checkAll(this,'check')" rerender="count,allcount" />
                        </apex:inputCheckbox>                          
                    </apex:facet>
                    <apex:inputcheckbox value="{!c.checked}" id="check" onchange="doCheckboxChange(this,'{!c.oaccount.Id}')" >                           
                    </apex:inputcheckbox> 
                    <apex:actionStatus id="selected" startText="Loading..."  stopText=""/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="mpb" status="TableUpdateStatus">
                            <apex:param name="SortField" value="Name" assignTo="{!SortField}" />
                            <apex:outputText value="{!$ObjectType.Account.Fields.Name.Label}{!IF(SortField=='Name',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputLink value="/{!c.oaccount.id}" target="_blank">{!c.oaccount.name}</apex:outputlink>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="mpb" status="TableUpdateStatus">
                            <apex:param name="SortField" value="Billingcity" assignTo="{!SortField}" />
                            <apex:outputText value="{!$ObjectType.Account.Fields.Billingcity.Label}{!IF(SortField=='Billingcity',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                    </apex:facet>
                     <apex:outputLabel >{!c.oaccount.billingcity}</apex:outputLabel>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="mpb" status="TableUpdateStatus">
                            <apex:param name="SortField" value="type" assignTo="{!SortField}" />
                            <apex:outputText value="{!$ObjectType.Account.Fields.type.Label}{!IF(SortField=='type',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputLabel >{!c.oaccount.type}</apex:outputLabel>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!SortToggle}" rerender="mpb" status="TableUpdateStatus">
                            <apex:param name="SortField" value="phone" assignTo="{!SortField}" />
                            <apex:outputText value="{!$ObjectType.Account.Fields.phone.Label}{!IF(SortField=='phone',IF(SortDirection='asc','▲','▼'),'')}" />
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputLabel >{!c.oaccount.phone}</apex:outputLabel>
                </apex:column>
               
            </apex:pageBlockTable>                   
            <apex:outputLabel value="[{!SelectedCount} records selected]" id="count"/>
            <apex:commandButton action="{!doPrevious}" rendered="{!hasPrevious}" value="Previous" style="color:red" rerender="out,table,table1"/>
            <apex:outputLabel rendered="{!NOT(hasPrevious)}" value="Previous" style="color:red" /> 
            <apex:outputLabel value=" (Page {!pageNumber} of {!totalPages}) " style="color:Blue" /> 
            <apex:commandButton action="{!doNext}" rendered="{!hasNext}" value="Next" style="color:green" rerender="out,table,table1"/>
            <apex:outputLabel rendered="{!NOT(hasNext)}" value="Next" style="color:green"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>



Apex Controller:
 
public with sharing class newProjectCreationController{
  
    
    private String QueryAccount;
     public String SortFieldSave;
    
    //public Integer Selectedaccid{get;set;}
    public Boolean showError{get;set;}
    public String a { get; set; }
    public String url;
    
    public boolean vBoolean = false;
    public integer noofadded{get;set;}
    //  private String baseQuery = 'Select ID, Name,phone,rating,accountnumber FROM Account ORDER BY NAME ASC Limit 5000';
    public String AccFilterId {get; set;}
    public string RecPerPage {get; set;}
    public list<SelectOption> RecPerPageOption {get; set;} 
    public String contextItem{get;set;}
    public String contextItem1{get;set;}

    public set<id> accountids;
   private List<accountSet> accountSetList{get;set;}
    public set<Account> selectedAccount;
    public boolean fals{get;set;}
      
        
    public newProjectCreationController()
    {
       
       
        
        fals=false;
        this.accountSetList = new List<accountSet>();
        this.selectedAccount = new set<account>();
        this.accountids = new set<id>();
        //records for page initialization
        RecPerPageOption = new list<SelectOption>();
        RecPerPageOption.add(new SelectOption('10','10'));
        RecPerPageOption.add(new SelectOption('25','25'));
        RecPerPageOption.add(new SelectOption('50','50'));
        RecPerPageOption.add(new SelectOption('100','100'));
        RecPerPageOption.add(new SelectOption('200','200'));
        RecPerPage = '10'; //default records per page
       BuildQuery(); 
    }
    public ApexPages.StandardSetController AccSetController {
        get{            
            if(AccSetController == null){
                AccSetController = new ApexPages.StandardSetController(Database.getQueryLocator(QueryAccount));
                //AccSetController.setPageSize(pageSize);
                this.AccSetController.setpageNumber(1);
                // sets the number of records in each page set
                this.AccSetController.setPageSize(Integer.valueOf(RecPerPage));
                // We have to set FilterId after Pagesize, else it will not work
                if(AccFilterId != null)
                {
                    AccSetController.setFilterId(AccFilterId);
                }
            }
            return AccSetController;
        }set;
    }
    
    //public newProjectCreationController(ApexPages.StandardSetController c) {   }
    
    public List<accountSet> getCurrentList() { 
          
        updateSelectedAccount();
        accountSetList = new List<accountSet>();
        for (account category : (List<account>)AccSetController.getRecords()){
            if(selectedaccount.contains(category))
                accountSetList.add(new accountSet(category,'true'));
            else
                accountSetList.add(new accountSet(category));
        }
        
        fals=false;
        system.debug('Allaccounts   '+accountSetList.size());
        return accountSetList;
    }
     
    
    
    Private void updateSelectedAccount(){
        //contactSetList.clear();
        
        for(accountSet cs:accountSetList ){
            if(cs.checked)
                selectedAccount.add(cs.oaccount);
            else{
                if(selectedAccount.contains(cs.oaccount))
                    selectedAccount.remove(cs.oaccount);
                
            }
            
        }
    }
    
    public class AccountSet {
        public Boolean checked{ get; set; }
        public account oAccount { get; set;}
        public AccountSet(){
            oAccount = new Account();
            checked = false;
        }
        public AccountSet(account a){
            oAccount = a;
            checked = false;
        }
        public accountSet(account a,string s){
            oAccount = a;
            checked = true;
        }
    }
    
    
    //Get all available list view for Account
    public SelectOption[] getAccountExistingViews(){
        return AccSetController.getListViewOptions();
    }
    
    /**
    * Reset List View
    */
    public PageReference resetFilter()
    {  
        selectedaccount.clear();
        accountSetList.clear();
        AccSetController = null;
        AccSetController.setPageNumber(1);
        
        return null;
    }
    
    
    /*
    *   return count of selected items
    */
    
    public void doSelectItem(){
        
        if(contextItem!=null)
            accountids.add(this.contextItem);
        
    }
    
    public void doDeselectItem(){
        
        accountids.remove(this.contextItem);
        
    }
    
    /*
    *   return count of selected items
    */
    public Integer getSelectedCount(){
        
        accountids.clear();
        for(account acc: selectedaccount){
            accountids.add(acc.id);
        }
        //selectedaccount.clear();
        return this.accountids.size();
        
    }
    
    /*
    *   advance to next page
    */
    public void doNext(){
        
        if(this.AccSetController.getHasNext())
            this.AccSetController.next();
        
    }
    
    /*
    *   advance to previous page
    */
    public void doPrevious(){
        
        if(this.AccSetController.getHasPrevious())
            this.AccSetController.previous();
        
    }
    /*
    *   return whether previous page exists
    */
    public Boolean getHasPrevious(){
        
        return this.AccSetController.getHasPrevious();
        
    }
    
    /*
    *   return whether next page exists
    */
    public Boolean getHasNext(){
        
        return this.AccSetController.getHasNext();
        
    }
    
    /*
    *   return page number
    */
    public Integer getPageNumber(){
        
        return this.AccSetController.getPageNumber();
        
    }
    
    /*
    *    return total pages
    */
    Public Integer getTotalPages(){
        
        Decimal totalSize = this.AccSetController.getResultSize();
        Decimal pageSize = this.AccSetController.getPageSize();
        
        Decimal pages = totalSize/pageSize;
        
        return (Integer)pages.round(System.RoundingMode.CEILING);
    }
    
    
   
     /***
    * BuildQuery - build query command for list selection change
    ***/
    public void BuildQuery() {
        AccSetController = null;
        QueryAccount = 'SELECT Name,Id,Type,Phone,BillingCity' +
            ' FROM Account'; 
 
        QueryAccount += ' ORDER BY ' + String.escapeSingleQuotes(SortField) + ' ' + String.escapeSingleQuotes(SortDirection) + ' LIMIT 1000';
        
        system.debug('QueryAccount:' + QueryAccount);
        
    }
     /***
    * SortToggle - toggles the sorting of query from asc<-->desc
    ***/
    public void SortToggle() {
        SortDirection = SortDirection.equals('asc') ? 'desc' : 'asc';
      
        BuildQuery();
    }
  /***
    * SortField - return sort by field. Default to Name
    ***/
    public String SortField {
        get { if (SortField == null) {SortField = 'Name'; } return SortField;  }
        set; 
    }
     /***
    * SortDirection - return sort direction. Default ascending(asc)
    ***/
    public String SortDirection {
        get { if (SortDirection == null) {  SortDirection = 'asc'; }
        
         return SortDirection;  }
        set;
    }
 
}

thanks in advance............
 
Hi,

I have displayed visualforce page in standard page layout
as shown in the below screen
User-added image
i have displayed two links in visualforce page.

when i click on like it gets open new window. it is working fine in desk top application.

 
coming to salesforce1

it's taking two steps to open link like below screens

User-added image

visualforce code:

<apex:page standardController="task" extensions="SurveyandStepsController" docType="html-5.0">
    <apex:form >
        <script>
            function navigate(){
                var proid = '{!prosteps.id}';
                var tasid1 = '{!taskId}';
                var steUrl = '/apex/StepsAttachmentShow?id='+proid+'&taskid='+tasid1;
                 if( (typeof sforce != 'undefined') && (sforce != null) ) {
                  // Salesforce1 navigation
                  sforce.one.navigateToURL(steUrl);
                } 
                else {
                  window.open(steUrl);
                }
                
            }
        
        function navigatesurvey(){
                var surveyid = '{!surveyid.id}';
                var accid = '{!correnttask.Whatid}';
                var tasid = '{!taskId}';
                var surveyUrl = '/apex/TakeSurvey?id='+surveyid+'&Accname='+accid+'&taskid='+tasid;         
                 if( (typeof sforce != 'undefined') && (sforce != null) ) {
                  // Salesforce1 navigation
                  sforce.one.navigateToURL(surveyUrl);
                } 
                else {
                  window.open(surveyUrl);
                }
                
            }
        </script>        
            <div >
                <br/>            
                <div style="height:100%;width:50%;float:left;">
                    <b><apex:commandLink onclick="navigatesurvey();return false;" value="Click here for Survey" rendered="{!surveyid != null }"/></b>
                </div>
                <div style="height:100%;width:50%;float:right;">
                    <b> <apex:commandLink onclick="navigate();return false;" value="Click here for Steps" rendered="{!prosteps != null }"/></b>
                </div>
                
            </div>           
  
   </apex:form>
   
</apex:page>

I am new to salesforce1

can anyone knows kingly suggest me how to implement


Thanks in advance

 
I am getting the above error in the fllowing code how can i avoid this error..

Can any body suggest me how to fix this error

Apex Code:

       list<Lead_Referral__c> conlist=new list<Lead_Referral__c>();
       
        conlist = [select id, OwnerId,Contact_Name__c from Lead_Referral__c where id =: 'a06K0000009qFoT' or id =: 'a06K000000A4Yn9' or id                         =:'a06K0000009qG3s'];       
        Task LFUActivity = new Task();
        list<Task> LFUActlist = new list<Task>();
          
for(integer j=0;j<conlist.size();j++){
    LFUActivity.ownerId = conlist[j].OwnerId;
                LFUActivity.ActivityDate = system.today();
                LFUActivity.Priority = 'low';
                LFUActivity.Status = 'Completed';
                LFUActivity.Subject = 'JELD-WEN Lead Status Update Request Sent';
                LFUActivity.Type = 'Automated Follow Up';
                LFUActivity.WhatId = conlist[j].id;
                LFUActivity.WhoId = conlist[j].Contact_Name__c;
                LFUActivity.description = 'body1';
                LFUActlist.add(LFUActivity);
            }
           
             insert LFUActlist;


Thanks In Advance..
HI,

Here i am facing issue with inlinedit in apex:pageblock table...

i am dispalying some list of records in a table..

see the below code:

Visualforce page:

<apex:page standardController="Project__c" extensions="projectopportunities" docType="xhtml-1.0-strict"> 
    <apex:form >
    <div id='inCompletedproj' style='border:0px solid;overflow-y:scroll;height:200px;'>
    <apex:pageBlock id="tbid" mode="inlineedit"> 
         <apex:pageBlockButtons location="top"> 
                <apex:commandButton action="{!addnewopp}" value="Add New Opportunity" onclick="window.open('/apex/new_opportunity_for_project_page?pid={!proid}')"/>                
           </apex:pageBlockButtons>
            <apex:pageBlockButtons location="bottom"> 
               <apex:commandButton action="{!saveme}" id="saveButton" value="Save" />
               <apex:commandButton id="cancelButton" value="Cancel"/> 
           </apex:pageBlockButtons>
         <apex:pageMessages></apex:pageMessages>
           <apex:pageBlockTable value="{!opplist}" var="p" id="tableid">            
          <apex:column >
                    <apex:outputlink Onclick="window.open('/{!p.id}/e?retURL={!p.Project__c}');return false;"><div style="color:blue;">Edit</div></apex:outputlink> 
                    <apex:facet name="header">Action</apex:facet>
                </apex:column>
                <apex:column >
                    <apex:outputField value="{!p.accountid}">
                        <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                        <apex:facet name="header">Account Name</apex:facet>
                </apex:column>
                <apex:column value="{!p.name}">
                    <!--<apex:outputField value="{!p.name}"/>--> 
                        <apex:facet name="header">Opportunity Name</apex:facet>
                </apex:column>                
               <apex:column >
                   <apex:outputField value="{!p.Amount_Integer__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Dealer Cost</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.CloseDate}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Est. Close Date</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.StageName}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Stage</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.Product_Group__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Product Group</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.SubProductGroup__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">SubProduct Group</apex:facet>
               </apex:column>
       </apex:pageBlockTable>
   
</apex:pageBlock> 
        </div>
</apex:form> 
</apex:page>

Apex Class:

public with sharing class projectopportunities{
   
    public id proid{get;set;}
    public List<Opportunity> opplist{get;set;}   
    public projectopportunities(){}   
    public String Url{get;set;}
    public RecordType RT;
    public projectopportunities(ApexPages.StandardController controller) {      
        //opplist = new List<Opportunity>();
        proid = apexpages.currentpage().getparameters().get('id'); 
         RT = [Select Id From RecordType where sobjecttype = 'Opportunity' and name ='project'];
        opplist= [Select Id,Name,Accountid,Project__c,Amount_Integer__c,CloseDate,StageName,Product_Group__c,SubProductGroup__c From Opportunity where Project__c =: proid and recordtypeid =:RT.id];   
    }
   
    public pagereference saveme()
    {
       
        try
        {     
            update opplist;
            opplist.clear();
            opplist= [Select Id,Name,Accountid,Project__c,Amount_Integer__c,CloseDate,StageName,Product_Group__c,SubProductGroup__c From Opportunity where Project__c =: proid and recordtypeid =:RT.id];
        }  
        catch(Exception e)
        {
            System.debug('Exception occurred '+String.valueOf(e));
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,'Only specify the winner account in the Account Name field for a Won Opportunity.'));
        }
        return null;
    }
   
    public pagereference addnewopp(){      
       
        //return new PageReference('/apex/new_opportunity_for_project_page?pid='+proid);
        return null;
        
    }
   
}



here i am updating all records which are in table......

here i want to update only particular record  
HI All,

I am struggling with updation os one task record based on other task......

here is
i have task1 and task2.

task 1 is related to account and task2 is related to custom object

here we have on common field in task call accid.
in accid we have account id in both tasks.

here my requirment is to task2 when i am going to update task1............

Please Can anyone suggest me it's urgent 

I have developed the below code

trigger TaskAU on Task (before update)
{
    set<string> vProjAccId = new set<string>();
   
    for(Task t : trigger.new)
    {
        vProjAccId.add(t.ProjectAccountIDs__c);
       
        system.debug('---------------->'+vProjAccId);
    }
   
    list<Task> vLstTask = [SELECT Id,ProjectAccountIDs__c,ActivityDate,Priority,Status,Subject,OwnerId FROM Task
                        where ProjectAccountIDs__c IN : vProjAccId];
      system.debug('=============>'+vLstTask.size());
   // Task vTask;   
   
   // list<task> vLstTasks = new list<task>();               
    for(Task tas : trigger.new)
    {
       system.debug('################'+tas);
        //vTask = trigger.oldMap.get9tas.id);
        for(Task vTas : vLstTask)
        {
         
           if(vTas.ProjectAccountIDs__c == tas.ProjectAccountIDs__c)
           {
              vTas.ActivityDate = tas.ActivityDate;
              vTas.Priority = tas.Priority;
              vTas.Status = tas.Status;
              vTas.Subject = tas.Subject ;
             
              system.debug('@@@@@@@@@@@@@@@@@@@@'+vTas);
            
           }
            //vLstTasks.add(vTas);
        }//system.debug('@@@@@@@@@@@@@@@@@@@@'+vLstTask);
    }
   
    //update vLstTask;
    
}
Hi Guys,

How to attache one file to multiple tasks at time from visualforce.

Here i am developing visualforce page for mass task creation and i am going to attache one file for all the tasks.
Here i am uploading file at one time, that file only i am going to attach to multiple tasks

Thanks in advance.....................
Hello

Now my salesforce user interface is looking like below screen.


 User-added image
i want like below screen
User-added image
How to change user inter face in salesforce?

I traid in setup-->app setup-->custamise-->user interface

Help me if anyone knows 
thanks in advance
Hi

I have two users with same profile but  different roles

user1 is created some 3 reports.

Now i want to give access to user2 that all reports......





I have created custom detail button(added visualforc page) in account object, it is visible in salesforce 1, But when i click on the button it will not showing anything.

This visualforce page was enabled Available for Salesforce mobile apps option.
Hi

I have two users with same profile but  different roles

user1 is created some 3 reports.

Now i want to give access to user2 that all reports......





Hi Developers,

I got one requirment regarding calendar in salesforce.

I want functionaly like when i click on any date in salesforce standard calendar i want open pop up with visualforce page..

this functionaliy only in standard salesforce calendar not visualforce. just i want open visualforc as with new window from calendar.

If any body know please share with me.

Thanks in advance.
Hi,

I have displayed visualforce page in standard page layout
as shown in the below screen
User-added image
i have displayed two links in visualforce page.

when i click on like it gets open new window. it is working fine in desk top application.

 
coming to salesforce1

it's taking two steps to open link like below screens

User-added image

visualforce code:

<apex:page standardController="task" extensions="SurveyandStepsController" docType="html-5.0">
    <apex:form >
        <script>
            function navigate(){
                var proid = '{!prosteps.id}';
                var tasid1 = '{!taskId}';
                var steUrl = '/apex/StepsAttachmentShow?id='+proid+'&taskid='+tasid1;
                 if( (typeof sforce != 'undefined') && (sforce != null) ) {
                  // Salesforce1 navigation
                  sforce.one.navigateToURL(steUrl);
                } 
                else {
                  window.open(steUrl);
                }
                
            }
        
        function navigatesurvey(){
                var surveyid = '{!surveyid.id}';
                var accid = '{!correnttask.Whatid}';
                var tasid = '{!taskId}';
                var surveyUrl = '/apex/TakeSurvey?id='+surveyid+'&Accname='+accid+'&taskid='+tasid;         
                 if( (typeof sforce != 'undefined') && (sforce != null) ) {
                  // Salesforce1 navigation
                  sforce.one.navigateToURL(surveyUrl);
                } 
                else {
                  window.open(surveyUrl);
                }
                
            }
        </script>        
            <div >
                <br/>            
                <div style="height:100%;width:50%;float:left;">
                    <b><apex:commandLink onclick="navigatesurvey();return false;" value="Click here for Survey" rendered="{!surveyid != null }"/></b>
                </div>
                <div style="height:100%;width:50%;float:right;">
                    <b> <apex:commandLink onclick="navigate();return false;" value="Click here for Steps" rendered="{!prosteps != null }"/></b>
                </div>
                
            </div>           
  
   </apex:form>
   
</apex:page>

I am new to salesforce1

can anyone knows kingly suggest me how to implement


Thanks in advance

 
I am getting the above error in the fllowing code how can i avoid this error..

Can any body suggest me how to fix this error

Apex Code:

       list<Lead_Referral__c> conlist=new list<Lead_Referral__c>();
       
        conlist = [select id, OwnerId,Contact_Name__c from Lead_Referral__c where id =: 'a06K0000009qFoT' or id =: 'a06K000000A4Yn9' or id                         =:'a06K0000009qG3s'];       
        Task LFUActivity = new Task();
        list<Task> LFUActlist = new list<Task>();
          
for(integer j=0;j<conlist.size();j++){
    LFUActivity.ownerId = conlist[j].OwnerId;
                LFUActivity.ActivityDate = system.today();
                LFUActivity.Priority = 'low';
                LFUActivity.Status = 'Completed';
                LFUActivity.Subject = 'JELD-WEN Lead Status Update Request Sent';
                LFUActivity.Type = 'Automated Follow Up';
                LFUActivity.WhatId = conlist[j].id;
                LFUActivity.WhoId = conlist[j].Contact_Name__c;
                LFUActivity.description = 'body1';
                LFUActlist.add(LFUActivity);
            }
           
             insert LFUActlist;


Thanks In Advance..
HI,

Here i am facing issue with inlinedit in apex:pageblock table...

i am dispalying some list of records in a table..

see the below code:

Visualforce page:

<apex:page standardController="Project__c" extensions="projectopportunities" docType="xhtml-1.0-strict"> 
    <apex:form >
    <div id='inCompletedproj' style='border:0px solid;overflow-y:scroll;height:200px;'>
    <apex:pageBlock id="tbid" mode="inlineedit"> 
         <apex:pageBlockButtons location="top"> 
                <apex:commandButton action="{!addnewopp}" value="Add New Opportunity" onclick="window.open('/apex/new_opportunity_for_project_page?pid={!proid}')"/>                
           </apex:pageBlockButtons>
            <apex:pageBlockButtons location="bottom"> 
               <apex:commandButton action="{!saveme}" id="saveButton" value="Save" />
               <apex:commandButton id="cancelButton" value="Cancel"/> 
           </apex:pageBlockButtons>
         <apex:pageMessages></apex:pageMessages>
           <apex:pageBlockTable value="{!opplist}" var="p" id="tableid">            
          <apex:column >
                    <apex:outputlink Onclick="window.open('/{!p.id}/e?retURL={!p.Project__c}');return false;"><div style="color:blue;">Edit</div></apex:outputlink> 
                    <apex:facet name="header">Action</apex:facet>
                </apex:column>
                <apex:column >
                    <apex:outputField value="{!p.accountid}">
                        <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                        <apex:facet name="header">Account Name</apex:facet>
                </apex:column>
                <apex:column value="{!p.name}">
                    <!--<apex:outputField value="{!p.name}"/>--> 
                        <apex:facet name="header">Opportunity Name</apex:facet>
                </apex:column>                
               <apex:column >
                   <apex:outputField value="{!p.Amount_Integer__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Dealer Cost</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.CloseDate}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Est. Close Date</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.StageName}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Stage</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.Product_Group__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">Product Group</apex:facet>
               </apex:column>
               <apex:column >
                   <apex:outputField value="{!p.SubProductGroup__c}">
                       <apex:inlineEditSupport showOnEdit="saveButton"
                            hideOnEdit="" event="ondblclick"
                            resetFunction="resetInlineEdit"/>
          </apex:outputField>
                   <apex:facet name="header">SubProduct Group</apex:facet>
               </apex:column>
       </apex:pageBlockTable>
   
</apex:pageBlock> 
        </div>
</apex:form> 
</apex:page>

Apex Class:

public with sharing class projectopportunities{
   
    public id proid{get;set;}
    public List<Opportunity> opplist{get;set;}   
    public projectopportunities(){}   
    public String Url{get;set;}
    public RecordType RT;
    public projectopportunities(ApexPages.StandardController controller) {      
        //opplist = new List<Opportunity>();
        proid = apexpages.currentpage().getparameters().get('id'); 
         RT = [Select Id From RecordType where sobjecttype = 'Opportunity' and name ='project'];
        opplist= [Select Id,Name,Accountid,Project__c,Amount_Integer__c,CloseDate,StageName,Product_Group__c,SubProductGroup__c From Opportunity where Project__c =: proid and recordtypeid =:RT.id];   
    }
   
    public pagereference saveme()
    {
       
        try
        {     
            update opplist;
            opplist.clear();
            opplist= [Select Id,Name,Accountid,Project__c,Amount_Integer__c,CloseDate,StageName,Product_Group__c,SubProductGroup__c From Opportunity where Project__c =: proid and recordtypeid =:RT.id];
        }  
        catch(Exception e)
        {
            System.debug('Exception occurred '+String.valueOf(e));
            ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error,'Only specify the winner account in the Account Name field for a Won Opportunity.'));
        }
        return null;
    }
   
    public pagereference addnewopp(){      
       
        //return new PageReference('/apex/new_opportunity_for_project_page?pid='+proid);
        return null;
        
    }
   
}



here i am updating all records which are in table......

here i want to update only particular record  
Hi Guys,

How to attache one file to multiple tasks at time from visualforce.

Here i am developing visualforce page for mass task creation and i am going to attache one file for all the tasks.
Here i am uploading file at one time, that file only i am going to attach to multiple tasks

Thanks in advance.....................
Hello

Now my salesforce user interface is looking like below screen.


 User-added image
i want like below screen
User-added image
How to change user inter face in salesforce?

I traid in setup-->app setup-->custamise-->user interface

Help me if anyone knows 
thanks in advance
I have created custom detail button(added visualforc page) in account object, it is visible in salesforce 1, But when i click on the button it will not showing anything.

This visualforce page was enabled Available for Salesforce mobile apps option.