function Commit_Time_Value(responseTime)
{
//***************************************************************************
//Created Created By Description
// This script checks the value of the " Service Level Response Time"
// and sets the value of the "Commit Time" field.
//************************************************************************
try
{
var lsTimeInDays = "" ;
var lsTimeInHours = "" ;
var lsCreatedTime ;
var lsCommitTime ;
lsCreatedTime = new Date(this.GetFieldValue("Created"));
switch(responseTime)
{
//Store the time in days or hours.
case "1 Day":
lsTimeInDays = "1" ;
break ;
case "2 Days":
lsTimeInDays = "2" ;
break ;
case "3 Days":
lsTimeInDays = "3" ;
break ;
case "4 Days":
lsTimeInDays = "4" ;
break ;
case "5 Days":
lsTimeInDays = "5" ;
break ;
case "6 Days"://IR 7.3 added
lsTimeInDays = "6" ;
break ;
case "10 Days":
lsTimeInDays = "10" ;
break ;
case "7 Days":
lsTimeInDays = "7" ;
break ;
case "N/A (not applicable)":
lsTimeInDays = "" ;
break ;
case "4 Hours":
lsTimeInHours = "4" ;
break ;
case "6 Hours":
lsTimeInHours = "6" ;
break ;
default:
break ;//Do nothing
}
if(lsTimeInDays != "")
{
//Increment time by No. of days * hours in a day * minutes in hour * seconds in min * milli secs in sec
lsCommitTime = CalculateCommit_Time_Excl_Wkds (lsCreatedTime, lsTimeInDays);
//lsCommitTime = new Date(lsCreatedTime.getTime() + lsTimeInDays*24*60*60*1000) ;
this.SetFieldValue("Commit Time",DateToString(lsCommitTime)) ;
}
else
{
if(lsTimeInHours != "")
{
//Increment time by No. of hours * minutes in hour * seconds in min * milli secs in sec
lsCommitTime = new Date(lsCreatedTime.getTime() + lsTimeInHours*60*60*1000) ;
this.SetFieldValue("Commit Time",DateToString(lsCommitTime)) ;
}
}
}
catch(e)
{
//Handle errors
var ls_error_text;
var le_new_exception;
ls_error_text = e.toString();
ls_error_text += " Error in Commit_Time_Value Method of ATC Service Request BC.";
le_new_exception = ToObject(ls_error_text);
throw le_new_exception;
}
finally
{
//Destroy objects
// responseTime = null;
lsCommitTime = null ;
lsCreatedTime = null ;
lsTimeInHours = null ;
lsTimeInDays = null ;
}
}
function CalculateCommit_Time_Excl_Wkds (SRCreatedDate,days)
{
//SRCreateDate = starting date, days = no. working days to add.
var i = 0;
var days_to_add = 0;
var dtCreatedDate = new Date();
while (i < (days))
{
dtCreatedDate = new Date(SRCreatedDate.getTime() + (days_to_add*24*60*60*1000));
//0 = Sunday, 6 = Saturday, if the date notequals a weekend day then increase by 1
if ((dtCreatedDate.getDay() != 5) &&(dtCreatedDate.getDay() != 6))
{
i = i + 1;
}
days_to_add = days_to_add + 1;
}
return new Date(SRCreatedDate.getTime() +days_to_add*24*60*60*1000);
}
{
//***************************************************************************
//Created Created By Description
// This script checks the value of the " Service Level Response Time"
// and sets the value of the "Commit Time" field.
//************************************************************************
try
{
var lsTimeInDays = "" ;
var lsTimeInHours = "" ;
var lsCreatedTime ;
var lsCommitTime ;
lsCreatedTime = new Date(this.GetFieldValue("Created"));
switch(responseTime)
{
//Store the time in days or hours.
case "1 Day":
lsTimeInDays = "1" ;
break ;
case "2 Days":
lsTimeInDays = "2" ;
break ;
case "3 Days":
lsTimeInDays = "3" ;
break ;
case "4 Days":
lsTimeInDays = "4" ;
break ;
case "5 Days":
lsTimeInDays = "5" ;
break ;
case "6 Days"://IR 7.3 added
lsTimeInDays = "6" ;
break ;
case "10 Days":
lsTimeInDays = "10" ;
break ;
case "7 Days":
lsTimeInDays = "7" ;
break ;
case "N/A (not applicable)":
lsTimeInDays = "" ;
break ;
case "4 Hours":
lsTimeInHours = "4" ;
break ;
case "6 Hours":
lsTimeInHours = "6" ;
break ;
default:
break ;//Do nothing
}
if(lsTimeInDays != "")
{
//Increment time by No. of days * hours in a day * minutes in hour * seconds in min * milli secs in sec
lsCommitTime = CalculateCommit_Time_Excl_Wkds (lsCreatedTime, lsTimeInDays);
//lsCommitTime = new Date(lsCreatedTime.getTime() + lsTimeInDays*24*60*60*1000) ;
this.SetFieldValue("Commit Time",DateToString(lsCommitTime)) ;
}
else
{
if(lsTimeInHours != "")
{
//Increment time by No. of hours * minutes in hour * seconds in min * milli secs in sec
lsCommitTime = new Date(lsCreatedTime.getTime() + lsTimeInHours*60*60*1000) ;
this.SetFieldValue("Commit Time",DateToString(lsCommitTime)) ;
}
}
}
catch(e)
{
//Handle errors
var ls_error_text;
var le_new_exception;
ls_error_text = e.toString();
ls_error_text += " Error in Commit_Time_Value Method of ATC Service Request BC.";
le_new_exception = ToObject(ls_error_text);
throw le_new_exception;
}
finally
{
//Destroy objects
// responseTime = null;
lsCommitTime = null ;
lsCreatedTime = null ;
lsTimeInHours = null ;
lsTimeInDays = null ;
}
}
function CalculateCommit_Time_Excl_Wkds (SRCreatedDate,days)
{
//SRCreateDate = starting date, days = no. working days to add.
var i = 0;
var days_to_add = 0;
var dtCreatedDate = new Date();
while (i < (days))
{
dtCreatedDate = new Date(SRCreatedDate.getTime() + (days_to_add*24*60*60*1000));
//0 = Sunday, 6 = Saturday, if the date notequals a weekend day then increase by 1
if ((dtCreatedDate.getDay() != 5) &&(dtCreatedDate.getDay() != 6))
{
i = i + 1;
}
days_to_add = days_to_add + 1;
}
return new Date(SRCreatedDate.getTime() +days_to_add*24*60*60*1000);
}
No comments:
Post a Comment