• Laxman Vattam
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 1
    Replies
How to take input for time on VF page? what data type needs to be used on the back end? what apex field needs to be used on VF page?
I'm developing a custom VF page for events and want to show date and time in two different fields. I created a new date field (startdate__c) to capture the date and temporary variable to capture time (timevalue). I'm planning to merge both date and time before saving the final startdatetime field. I'm unable to capture the time properly. Time variable is returning null. Please suggest a way to fix this issue
 
<apex:page standardController="Event" extensions="DateTimeClass" showHeader="true">

<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        <head>  
            <style>
                .ui-timepicker-wrapper {
                    overflow-y: auto;
                    height: 150px;
                    width:100%;
                    background: #fff;
                    border: 1px solid #ddd;
                    -webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);
                    -moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);
                    box-shadow:0 5px 10px rgba(0,0,0,0.2);
                    outline: none;
                    z-index: 10001;
                    margin: 0;
                    -webkit-border-radius:5px;
                    -moz-border-radius:5px;
                    border-radius:5px;
                    margin:3px 0 0 0 ;
                    padding:5px 0;
                }
                
                .ui-timepicker-wrapper.ui-timepicker-with-duration {
                    width: 13em;
                }
                
                .ui-timepicker-wrapper.ui-timepicker-with-duration.ui-timepicker-step-30,
                .ui-timepicker-wrapper.ui-timepicker-with-duration.ui-timepicker-step-60 {
                    width: 11em;
                }
                
                .ui-timepicker-list {
                    margin: 0;
                    padding: 0;
                    list-style: none;
                }
                
                .ui-timepicker-duration {
                    margin-left: 5px; color: #888;
                }
                
                .ui-timepicker-list:hover .ui-timepicker-duration {
                    color: #888;
                }
                
                .ui-timepicker-list li {
                    padding: 5px 0 5px 5px;
                    cursor: pointer;
                    white-space: nowrap;
                    color: #000;
                    list-style: none;
                    margin: 0;
                }
                
                .ui-timepicker-list:hover .ui-timepicker-selected {
                    background: #fff; color: #000;
                }
                
                li.ui-timepicker-selected,
                .ui-timepicker-list li:hover,
                .ui-timepicker-list .ui-timepicker-selected:hover {
                    background: #1980EC; color: #fff;
                }
                
                li.ui-timepicker-selected .ui-timepicker-duration,
                .ui-timepicker-list li:hover .ui-timepicker-duration {
                    color: #ccc;
                }
                
                .ui-timepicker-list li.ui-timepicker-disabled,
                .ui-timepicker-list li.ui-timepicker-disabled:hover,
                .ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
                    color: #888;
                    cursor: default;
                }
                
                .ui-timepicker-list li.ui-timepicker-disabled:hover,
                .ui-timepicker-list li.ui-timepicker-selected.ui-timepicker-disabled {
                    background: #f2f2f2;
                }
            </style>
            <c:CustomUX />
            <c:jQuery />
            <script type="text/javascript">
                window.typeahead || document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.9.0/jquery.timepicker.js"><\/script>');            
            </script>
            <apex:includeScript value="{!URLFOR($Resource.CustomActivity)}"/>
            
            <style>
                .slds-page-header.is-fixed + * {
                    margin-top: 46px;
                }
            </style>
            <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"/>
            <script>
                var j$ = jQuery.noConflict();
                j$(document).ready(function() {
                    bindData();
                    j$('#subject').click();
                });
                function bindData() {
                    j$('[id$=editTaskForm]').on('submit',function() {
                        j$('[id$=hiddenSubject]').val(j$('#subject').val());
                    });
                }
            </script>
            
        </head>
        <body>
            <apex:form id="createEventForm">
                <apex:pageMessages />
                <section class="slds">
                    <section class="body-content">
                        <div class="slds-page-header is-fixed" role="banner">
                            <div class="slds-media">
                                <div class="slds-media__body">
                                    <p class="slds-page-header__title slds-truncate slds-align-middle slds-float--left" title="Create Task">
                                       Add a Event
                                    </p>
                                    <apex:commandButton id="saveButton" styleClass="slds-button slds-button--neutral slds-float--right" action="{!CSave}" value="Save Event"/>  
                                   
                                    <a class="slds-button slds-button--neutral slds-float--right slds-m-right--small" onclick="history.go(-1); return false;">Cancel</a>
                                </div>
                            </div>
                        </div>     
      
                              <div class="slds-form-element is-required">
                                    <fieldset class="slds-form--compound">
                                        <div class="form-element__group">
                                            <label class="slds-form-element__label" for="start">
                                                <abbr class="slds-required" title="required">*</abbr>Start
                                            </label>
                                            <div class="slds-form-element__row">                                                
                                                <div class="slds-form-element slds-size--1-of-2">
                                                    <label class="slds-form-element__label" for="start-date">Date</label>                                                    
                                                    <div class="slds-form-element__control slds-input-has-icon slds-input-has-icon--right">
                                                        <a id="" href="#">
                                                            <svg aria-hidden="true" class="slds-input__icon input-text-default">
                                                                <use xlink:href="{!URLFOR($Resource.CustomUX, '/icons/utility-sprite/svg/symbols.svg#event')}"></use>
                                                            </svg>
                                                        </a>                                                          
                                                        <apex:inputfield value="{!eventObj.StartDate__c}" styleClass="slds-input js-datepicker" id="StartDate" />
                                                    </div>   
                                                </div>
                                                
                                                <div class="slds-form-element slds-size--1-of-2">
                                                    <label class="slds-form-element__label" for="start-time">Time</label>
                                                    <div class="slds-form-element__control slds-input-has-icon slds-input-has-icon--right has-timepicker">
                                                        <a id="" href="#">
                                                            <svg aria-hidden="true" class="slds-input__icon input-text-default">
                                                                <use xlink:href="{!URLFOR($Resource.CustomUX, '/icons/utility-sprite/svg/symbols.svg#clock')}"></use>
                                                            </svg>
                                                        </a>                                                           
                                                        <apex:inputText value="{!TimeValue}" styleClass="slds-input timepicker" id="StartTime" />
                                                        <!-- <apex:inputHidden id="startTime2" required="true"/> -->
                                                    </div> 
                                                </div>
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                                
                              </section>
                              </section>
            </apex:form>
        </body>
    </html>       
</apex:page>
 
public class DateTimeClass {

    
    
    private ApexPages.StandardController controller;
    public String eventId{get;set;}
    public Event eventObj{get;set;}    
    private String retURL{get;set;}
    public String startDate{get;set;}
    public String startHour{get;set;}
    public String endDate{get;set;}
    public String endHour{get;set;}
    
    Public datetime ControllerValue = System.Now();
    public String TimeValue {
        get {        
              return TimeValue;
         }
         set {  
            Time tm = ControllerValue.time();
            string TimeValue = string.valueOf(tm);
            system.debug('place6a' + TimeValue );     
            // Return TimeValue;    
            
         }  
    }
        
    public DateTimeClass(ApexPages.StandardController stdController) {
        this.controller = stdController;
        eventObj = (Event)stdController.getrecord();
        
        //logic for handling datetime
        eventObj.StartDateTime = System.Now();
        eventObj.StartDate__c = eventObj.StartDateTime.date();
        ControllerValue = System.Now();
        
                    
    }
     
    
    public PageReference CSave(){
        try{
            
            eventObj.Subject = 'abcd';
            eventObj.DurationInMinutes = 5; 
            eventObj.ActivityDateTime = eventObj.StartDateTime;
            eventObj.WhoId = '00Q8A000001O0j3';
            eventObj.OwnerId = UserInfo.getUserId();
                   
            system.debug('Start Date:' + eventObj.StartDate__c + 'Start Time:' + TimeValue + 'End Date:' + eventObj.EndDateTime);
            
            insert eventObj;
            
        }
        catch(Exception e)
        {
            
        }
        
        PageReference eventPage = new ApexPages.StandardController(controller.getRecord()).view();
        eventPage.setRedirect(true);
        return eventPage;
    }
    
    public PageReference cancel(){
        return controller.cancel();
    }


}

 
We are developing new VF pages to be launched with custom action for lightning. But we don't want them to be available on Salesforce1. As we are only able to add custom actions commonly to Salesforce1 and Lightning in the current page layouts how do we just make the custom actions available only for Lightning and not for Salesforce1? This is really a show stopper for our project and we are stuck on this and unable to proceed. Any ideas on how to overcome this problem.
I'm executing apex code based on UserInfo.getUiThemeDisplayed(). If the user is in lightning mode (UserInfo.getUiThemeDisplayed() =='Theme4d'), I execute part of code and if the user is in Classic mode (UserInfo.getUiThemeDisplayed() !='Theme4d') I execute other part of code.

While writing test class, it is by default going to Classic mode part of code. To cover the lightning part of code, I have created test user with UserPreferencesLightningExperiencePreferred = true. Even with system.runas this user, user is not being considered as lightning mode and my other part of apex code is not getting covered. how to switch the user to lightning mode.

Basically system.assert(UserInfo.getUiThemeDisplayed() =='Theme4d','ERROR: Theme is not lightning...'); is failing
Is there any way to cutomize classic visualforce page to look like lightning VF page (without to switching to lightning)? 

My requirement is to build a new VF page that is about to be used in salesforce classic but the styling should be like lightning.

 
I need to write a trigger to recognise non UTF-8 characters entered into name field of account and set some custom flag when user enters non UTF-8 characters. I started with below sample testing logic but it doesnt work. I always get the output as 'Non Match' in the below example. Please guide me on what is missing here. Open for alternate solutions as well.

Note: I just started with alphabets and numbers but need to change the logic to identify all UTF-8 characters
String FirstName = 'Fred';
Pattern regexPattern = Pattern.compile('[a-zA-Z_0-9]');
Matcher regexMatcher = regexPattern.matcher(FirstName);

if (!regexMatcher.matches()) {
    System.debug(LoggingLevel.Debug, 'No Matches');
} else {
    System.debug(LoggingLevel.Debug, 'Matches');
}
My client wants to understand the percentage of records (specifically opportunities/accounts) from mobile vs desktop. They basically want to understand the percent of usage of mobile salesforce. Is there any way to differenciate records created from desktop vs mobile? Any other ideas to identify the usage statistics of salesforce from mobile?
How to take input for time on VF page? what data type needs to be used on the back end? what apex field needs to be used on VF page?