locked
How do I insert a call timer into CRM 4.0 for the activity Phone Call? RRS feed

  • Question

  • I have a call timer that was developed in Java for a client.  The client wants to be able to start a call timer in the Activity Phone Call to record the duration of time with a customer.  Thus, when the call timer is stoped, the duration is recorded into a field in the phone call actitivy form.  I also have some XML that is for the ISV config file, but is was written for vs. 3.0.  I have 2 quesitons:

     

    1)  Can I insert the XML into the isv.config file for vs. 4.0?  If so what changes (if any) do I need to make before uploading?

    2)  How do I insert the call time into CRM so it appears on the phone call form?  How do I have the duration of time map to a field in the phone call form?

     

    I have listed the XML and Java bellow.  Any help would be greatly appreciated.  Thanks! Bill Kreuder

     

    XML for isv.config file (written for vs. 3.0):

     

    - <ImportExportXml version="3.0.5300.0">
      <Entities />
    - <IsvConfig>
    <![CDATA[
    <configuration version="3.0.0000.0">
    	<Root />
    	<Entities>
    		<Entity name="phonecall">
    			<ToolBar ValidForCreate="1" ValidForUpdate="0">
    				<Button
    					Title="Time this call"
    					ToolTip="Use this to time the duration of this call"
    					Icon="/CallTimer/timer.gif"
    					Url="/CallTimer/timer.htm"
    					WinMode="2"
    					WinParams="dialogHeight:240px;dialogWidth:340px;"
    				/>
    			</ToolBar>
    		</Entity>
    	</Entities>
    </configuration>
      ]]>
      </IsvConfig>
      <EntityMaps />
      <EntityRelationships />
      </ImportExportXml>
     
    Code for Call Timer:
     
    <html>
    <title>CRM Phone Call Timer</title>
    <style>
     DIV.timerBox
     {
      width: 205px;
      font-family: tahoma;
      font-size: 18px;
      font-weight: bold;
      background-color: #000000;
      color: #00FF00;
      padding: 5px;
      text-align: center;
      border: 1px solid #ffffff;
      border-top: 1px solid #666666;
      border-left: 1px solid #666666;
      margin-bottom: 5px;
     }
     
     BUTTON
     {
      width: 65px;
      margin-right: 5px;
      filter: progidBig SmileXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#ffffff, EndColorStr=#cecfde);
      cursor: hand;
      font-size: 11px;
      padding-left: 5px;
      padding-right: 5px;
      border: 1px solid #7b9ebd;
     }
     BODY
     {
      padding: 0px;
      margin: 0px;
      border: 0px;
      background-color[:#]EEF0F6;
      overflow: hidden;
     }
     
     BODY, TD
     {
      font-family: arial;
      font-size: 12px;
     }
     
     TD.body
     {
      border-bottom:  solid 1px #cccccc;
      text-align: center;
     }
     
     TD.header
     {
      background-color[:#]63769B;
      color:   #ffffff; 
      border-bottom: 1px solid #485673;
      height:   60px;
      vertical-align: top;
      padding:  8px;
     }
     
     TD.footer
     {
      text-align:  right;
      border-top:  1px solid #ffffff;
      padding:  10px;
      height:   32px;
      background-color: #EEF0F6;
     }
    </style>
    <script language="javascript">
     
     // Globals
     var _iTimerSecondValue = 0;
     var _iTimerMinuteValue = 0;
     var _iTimerHourValue = 0;
     var _iTimerId = 0;
     
     // Starts the timer
     function startTimer()
     {
      // Update UI
      butStart.disabled = true;
      butOk.disabled = false;
      butStop.disabled = false;
      
      // We don't want to wait a full second before the first tick
      incrementTimer();
      
      // Kick off the timer to update the timer every second
      _iTimerId = window.setInterval(incrementTimer, 1000);
     }
     
     // Stops the timer
     function stopTimer()
     {
      // Update UI
      butStart.disabled = false;
      butStop.disabled = true;
       
      window.clearInterval(_iTimerId);
      _iTimerId = 0;
     }
     
     // Resets the timer back to the way it was when the page first loaded
     function resetTimer()
     {
      // Update UI
      butOk.disabled = true;
      
      // Stop the timer
      stopTimer();
      
      // Reset everything
      _iTimerSecondValue = 0;
      _iTimerMinuteValue = 0;
      _iTimerHourValue = 0;
      
      // Reset the display
      updateDisplay();
     }
     
     // Increments and manages the timer values
     function incrementTimer()
     {
      // Update the display
      updateDisplay();
      
      if (_iTimerSecondValue == 59)
      {
       _iTimerSecondValue = 0;
       
       if (_iTimerMinuteValue == 59)
       {
        _iTimerMinuteValue = 0;
        
        _iTimerHourValue++;
       }
       else
       {
        _iTimerMinuteValue++;
       }
      }
      else
      {  
       // Add a second
       _iTimerSecondValue++;
      }
     }
     
     // Updates the display with the current timer value
     function updateDisplay()
     {
      // Format the string with a preceeding "0" if required
      var sHour = (_iTimerHourValue < 10) ? "0" + _iTimerHourValue : _iTimerHourValue;
      var sMinute = (_iTimerMinuteValue < 10) ? "0" + _iTimerMinuteValue : _iTimerMinuteValue;
      var sSecond = (_iTimerSecondValue < 10) ? "0" + _iTimerSecondValue : _iTimerSecondValue;
      
      // Update the UI
      divTimer.innerText = sHour + ":" + sMinute + ":" + sSecond;
     }
     // Cancels the timer dialog
     function cancel()
     {
      stopTimer();
      window.close();
     }
     
     // Applys the timer's value to the parent form and closes the dialog
     function ok()
     {
      stopTimer();
      
      // Get a pointer to the parent window
      var oParent = window.dialogArguments;
      
      // Round to the nearest minute
      _iTimerMinuteValue = (_iTimerSecondValue >= 30) ? _iTimerMinuteValue + 1 : _iTimerMinuteValue;
      // Total the minutes
      var iTotalMinutes = (_iTimerHourValue * 60) + _iTimerMinuteValue;
      
      // If the timer is less than 1 minute, round up
      if (iTotalMinutes < 1)
      {
       iTotalMinutes = 1;
      }
      
      // Set the duration
      oParent.document.crmForm.actualdurationminutes.DataValue = iTotalMinutes;
      
      window.close();
     }
     
    </script>
    <body>
    <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
     <tr>
      <td class="header">
      This call timer may be used to time the length of your call.  When finished, press "OK" and the duration of the call
      activity will be automatically populated.
      </td>
     </tr>
     <tr>
      <td class="body">
       <div class="timerBox" id="divTimer">00:00:00</div>
       <button id="butStart" onclick="startTimer();" accessKey="S"><u>S</u>tart</button>
       <button id="butStop" onclick="stopTimer();" accessKey="P" disabled><u>P</u>ause</button>
       <button id="butReset" onclick="resetTimer();" accessKey="R"><u>R</u>eset</button>
      </td>
     </tr>
     <tr>
      <td class="footer">
       <button id="butOk" onclick="ok();" disabled>OK</button>
       <button id="butCancel" onclick="cancel();">Cancel</button>
      </td>
     </tr>
    </table>
    </body>
    </html>
     
     
    Thursday, July 31, 2008 3:46 PM

Answers

  • wkreuder,

     

    In CRM 4.0, you can download ISV.config on the customization entity area, then change it, import it to CRM.

    I have looked through your code, in ISV.config, you need to change it to:

     

    Code Snippet
     <Entity name="phonecall">
      <ToolBar ValidForCreate="1" ValidForUpdate="0">
       <Button Icon="/ISV/CallTimer/timer.gif" Url="/ISV/CallTimer/timer.htm" WinMode="2" WinParams="dialogHeight:240px;dialogWidth:340px;">
        <Titles><Title LCID="1033" Text="Time this call" /></Titles>
        <ToolTips><ToolTip LCID="1033" Text="Use this to time the duration of this call" /></ToolTips>
       </Button>
      </ToolBar>
     </Entity>

     

     

     

    Your htm page look good for me, it already does the job: copy minute to duration field:

     

    Code Snippet
    function ok()
     {
      stopTimer();
     
      // Get a pointer to the parent window
      var oParent = window.dialogArguments;
     
      // Round to the nearest minute
      _iTimerMinuteValue = (_iTimerSecondValue >= 30) ? _iTimerMinuteValue + 1 : _iTimerMinuteValue;
      // Total the minutes
      var iTotalMinutes = (_iTimerHourValue * 60) + _iTimerMinuteValue;
     
      // If the timer is less than 1 minute, round up
      if (iTotalMinutes < 1)
      {
       iTotalMinutes = 1;
      }
     
      // Set the duration
      oParent.document.crmForm.actualdurationminutes.DataValue = iTotalMinutes;
     
      window.close();
     }

     

     

     

    Cheers,

    Jim

    Friday, August 1, 2008 9:08 AM
    Moderator
  • Please notice that I have add a /ISV folder in front of CallTimer folder, so you may change it if you want.

     

    Jim

     

    Friday, August 1, 2008 9:10 AM
    Moderator

All replies

  • wkreuder,

     

    In CRM 4.0, you can download ISV.config on the customization entity area, then change it, import it to CRM.

    I have looked through your code, in ISV.config, you need to change it to:

     

    Code Snippet
     <Entity name="phonecall">
      <ToolBar ValidForCreate="1" ValidForUpdate="0">
       <Button Icon="/ISV/CallTimer/timer.gif" Url="/ISV/CallTimer/timer.htm" WinMode="2" WinParams="dialogHeight:240px;dialogWidth:340px;">
        <Titles><Title LCID="1033" Text="Time this call" /></Titles>
        <ToolTips><ToolTip LCID="1033" Text="Use this to time the duration of this call" /></ToolTips>
       </Button>
      </ToolBar>
     </Entity>

     

     

     

    Your htm page look good for me, it already does the job: copy minute to duration field:

     

    Code Snippet
    function ok()
     {
      stopTimer();
     
      // Get a pointer to the parent window
      var oParent = window.dialogArguments;
     
      // Round to the nearest minute
      _iTimerMinuteValue = (_iTimerSecondValue >= 30) ? _iTimerMinuteValue + 1 : _iTimerMinuteValue;
      // Total the minutes
      var iTotalMinutes = (_iTimerHourValue * 60) + _iTimerMinuteValue;
     
      // If the timer is less than 1 minute, round up
      if (iTotalMinutes < 1)
      {
       iTotalMinutes = 1;
      }
     
      // Set the duration
      oParent.document.crmForm.actualdurationminutes.DataValue = iTotalMinutes;
     
      window.close();
     }

     

     

     

    Cheers,

    Jim

    Friday, August 1, 2008 9:08 AM
    Moderator
  • Please notice that I have add a /ISV folder in front of CallTimer folder, so you may change it if you want.

     

    Jim

     

    Friday, August 1, 2008 9:10 AM
    Moderator
  • That worked thanks!  One more question, can I insert some code to have the timer record the date and time of the start and end date and time when I click ok?  I was going to use a date and time field in the Phone Call form for start and end.  Thanks!  Bill

    Monday, August 4, 2008 3:11 PM
  • Hi,

    I used this solution in my Dynamics crm 4.0 ( 4.0.7333.3822). but that not worked. the page load fine, but when you click on the start button nothing wrong. it stops, the timer don't work, you can not click on reset button. everything stay on pending. How can i solve it?

    Thanks

    Tuesday, January 20, 2015 8:33 AM
  • Hi,

    This solution doesn't work in my case, i'm using dynamics crm 4.0 (4.0.7333.3822). i do things that you described here. the timer page loads but action on button does nothing. it stayed on pending. the countdown timer don't work.

    Thanks for Help.

    Regards


    • Edited by dc74 Tuesday, January 20, 2015 9:13 AM mistake
    Tuesday, January 20, 2015 9:12 AM
  • Sorry,

    I made mistakes in my script. your solution works.

    Thanks

    Regards

    Tuesday, January 20, 2015 3:18 PM