AdvoLogix Help

Cloning Considerations for Custom TimeEdit

Updated on

Although we do not suggest bypassing the TimeEdit form, AdvoLogix provides support to override our Visualforce page. When doing so, among other precautions, organizations might also consider providing support for the Time Clone button.

Considerations

For organizations who may have overridden our TimeEdit Visualforce form (with a customized Visualforce page) they should consider the appropriate steps regarding Cloning functionality.

  • You may optionally remove the Clone button entirely. No further steps would be required.
  • Otherwise, ensure your custom solution supports Cloning functionality by following the steps provided below.

Steps to Implement Cloning

  1. From the Time object’s Buttons & Links, ensure the Clone button is using your overridden TimeEdit Visualforce page.

  2. You will also need to ensure your custom TimeEdit source code accommodates the Clone function. For example, the following code sample illustrates how this might be done. 
Example Source Code to Support Cloning

Please keep in mind your code and business requirements are unique. We have no way of completely identifying how your specific solution should be augmented to support cloning. The following source code is simply a guide for your developers to follow.

Your Custom TimeController Apex Class

1. Add the public property isClone to your controller class:

public  boolean     isClone     { get;private set; }


2. Within the TimeController constructor:

  • Populate the isClone property as follows:
isClone  = ApexPages.currentPage().getParameters().get('clone') == '1';
  • Add logic to clear any background processing fields for the cloned record:
if (isClone) {
            trecord.advpm__ActivityId__c            = '';
            trecord.advpm__ActivityName__c          = '';
            trecord.advpm__ContentId__c             = '';
            trecord.advpm__ContentName__c           = '';
            if (advpm.AdvologixUtilities.isLicensedUser('AcctSeed') && advpm.AdvologixUtilities.isLicensedUser('advAcctSeed'))
           trecord.put('advAcctSeed__Billing_Line__c', null);
 }

Where trecord is the variable bound to the Time Record in your controller class.


3. The processTimeRounding function should be updated to include the isClone flag in the TimeController class:

// To evaluate Time Rounding when time record is NEW or CLONE
if (con.getId() == null || isClone)
   trecord.advpm__Time_In_Hours__c = advpm.AdvologixUtilities.getTimeByTimeRounding( trecord.advpm__Time_In_Hours__c );

Your Custom TimeEdit Visualforce Page

1. Your overridden TimeEdit page header should accommodate the isClone flag to display the correct heading: Edit, or New.

<apex:sectionHeader title="{!$ObjectType.advpm__Time__c.label} Edit" subTitle="{!IF(advpm__Time__c.Id == null || isClone, 'New '+ $ObjectType.advpm__Time__c.label, advpm__Time__c.Name)}" />


2. The Time (in hours) inputField should be updated to include the isClone flag so  Time Rounding is triggered when the user changes the Time (in hours) value.

<apex:inputText value="{!advpm__Time__c.advpm__Time_In_Hours__c}" id="timeInHours">
          <apex:actionSupport event="onchange" action="{!processTimeRounding}" rendered="{!(advpm__Time__c.Id == null || isClone) && GlobalOptions.advpm__Enable_Time_Rounding__c==true && GlobalOptions.advpm__Incremental_Rounding_Value__c > 0}" rerender="msgs,timeInHours" status="loadingStatus" />
</apex:inputText>



Previous Article Timekeeping
Next Article Multi Timer⚡
Still need help? Click here!
AdvoLogix® is a registered trademark of AdvoLogix.com LLC a Texas Limited Liability Company. All references to other trademarks belonging to third parties that appear on this website, documentation, or other materials shall be understood to refer to those registered trademarks owned by others, and not to any trademark belonging to AdvoLogix. Otherwise, all material herein is the copyright of AdvoLogix.com LLC. All Rights Reserved.