RE: Can Someone help me with some JScript by Dodd
Dodd
Fri Sep 22 09:20:02 CDT 2006
Hey again...
I'm almost there... Being fairly slow with JScript, I've been yoinking code
from a variety of sources...
I created the Custom bit field, and so far, it works fine. Using some get
methods I was able to get an accurate duration time without utilizing custom
DateTime attributes.
Here's what I came up with:
debugger
var CurrentTime = new Date()
switch (crmForm.all.new_starttimer.DataValue)
{
case true:
debugger
alert("Phone Call Timer is on");
StartTimeHrs = CurrentTime.getHours();
StartTimeMins = CurrentTime.getMinutes();
crmForm.all.new_starttimer_c.innerText = "Stop Timer";
break;
case false:
debugger
alert("Phone Call Timer is off");
crmForm.all.new_starttimer_c.innerText = "Start Timer";
EndTimeHrs = CurrentTime.getHours();
EndTimeMins = CurrentTime.getMinutes();
FinalTimeHrs = EndTimeHrs - StartTimeHrs;
FinalTimeMins = EndTimeMins - StartTimeMins;
MyDuration = FinalTimeHrs + " Hours " + FinalTimeMins + " Minutes";
alert(MyDuration);
break;
}
The alert gives me the right value, now I just need to find a way to load
this value into the into the Duration Field...
crmForm.all.actualdurationminutes.DataValue = MyDuration won't work because
it doesn't equate to the values in the picklist.
So... I'm wondering if I can do 2 things:
1.) Assign new values to the picklist at runtime (OnLoad?) that would add up
to 3 Hours and 60 Minutes as Picklist Items (If I can figure out how to
assign a single new item, I can fuddle with this using an array function (to
save hard coding every single picklist value)
2.) If there are no Hours FinalTimeHrs = 0, I'd like to leave this out and
just put in the Minutes...
Again, if someone can help get the ball rolling (JScript Syntax for If/Then,
Syntax to add new items for the Phone Call form's OnLoad event (preferably
using an array)
Thanks!
--Dodd
"Dodd" wrote:
> Hey, I was wondering if someone could help figure out how to log realtime
> phone call durations... This is for telemarketers... (though it could be
> applied for many activity situations...
>
> The business scenario:
>
> Using the MS CRM RSS feed add-on, the telemarketer is reminded of their call
> time (pretty nifty) if they are free, they open the Phone call record and
> once they connect, they'd click a bit field (checkbox) called "Start Timer".
> (If I get really fancy, I'd like the textbox label to change to "Stop Timer",
> which I think has been documented in this forum). This would start either one
> of two things:
>
> Triggered workflow that would update a hidden datetime (new_CallStart) field
> to now (date and time) upon execution of the workflow. It would wait for the
> checkbox to be un-checked. This would then update another hidden datetime
> field (new_CallStop) upon the execution of that workflow step.
>
> Now, all I need is for the onChange event of the Checkbox to give the
> DateDif of these two fields in hours and minutes. Once this value is greater
> than 00:00, this value would update the Duration Field.
>
> If I can get this to work (datedif-esq function) I can apply this to many
> activity scenarios... Some clients are real sticklers about how much time is
> spent on what activity... My goal is to keep this workflow on hand for future
> implmentations. Any help is greatly appreciated!
>
> --Dodd