Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, May 3, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Data & Imports Forums - SSIS/DTS
Forum to discuss using SQL SSIS or DTS to perform SalesLogix imports. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SSIS/DTS | New ThreadView:  Search:  
 Author  Thread: Need activex help
Valeda
Posts: 15
 
Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 10:20 AM
fiogf49gjkf0d
Hi,
I am attempting, for the first time, to create an activex task that determine the rundate of a job that executes daily. The rundate is the last work date. I have created a JScript to do this. I tested it and it works ok outside of DTS. What do I need to do to it to make it work it DTS? The script is below:

//**********************************************************************
// Java ActiveX Script
//************************************************************************
function setRunDate(runDate) {
var runDate;
var dateHoliday;
var today;
var d;
var runDay;
var runDt;

// Set the rundate to todays date minus 1
today = new Date();
runDate = new Date(today - 1);
runDay = (today.getDay() - 1);
runDt = new Date(runDate);

// Check to see if the new rundate is a weekend or holiday date
checkWeekendDate(runDate, runDay);
runDt = new Date(runDate);
runDate = (runDt.getMonth() + 1) + "/";
runDate += runDt.getDate() + "/";
runDate += runDt.getYear();
checkHoliday(runDate, dateHoliday);
if (dateHoliday == "y") {
checkWeekendDate(runDate,runDay);
}
return DTSTaskExecResult_Success(runDate;
}

function checkWeekendDate(runDate, runDay) {
// If rundate is Saturday(6) or Sunday(0), set it to Friday
if (runDay == 6) {
runDate = (new Date(runDt) - 1);
runDay = runDay - 1;
} else {
if (runDay == 0){
runDate = (new Date(runDt) - 2);
runDay = runDay - 1;
}
}
return runDate, runDay;
}

function checkHoliday(runDate, runDay) {
var memorialDay = new Date('5/29/2006');
var julyFourth = new Date('7/4/2006');
var laborDay = new Date('9/4/2006');
var thanksgivingDay = new Date('11/23/2006');
var dayAftThanksgiving = new Date('11/24/2006');
var Christmas = new Date('12/25/2006');
var newYearsDay = new Date('1/1/2007');
dateHoliday = 'n';

// If rundate is one of these holidays, set it back 1 day
if (runDate == memorialDay || runDate == julyFourth || runDate == laborDay || runDate == thanksgivingDay || runDate == Christmas || runDate == newYearsDay) {
runDate = (new Date(runDt) - 1);
runDay = runDay - 1;
runDt = new Date(runDate);
dateHoliday = 'y';
} else {
// If rundate is the day after Thanksgiving, set it back 2 days
if (runDate == dayAftThanksgiving) {
runDate = (new Date(runDt) - 2);
runDay = runDay - 2;
runDt = new Date(runDate);
dateHoliday = 'y';
}
}
return runDate, runDay;
}
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 11:50 AM
fiogf49gjkf0d
Your problem is with this line:

return DTSTaskExecResult_Success(runDate;


Aside from the fact that the end parens is missing, the DTSTaskExecResult_Success is not something you "pass" anything to. It is a static value that you would return to indicate success (or failure for it's counter-part DTSTaskExecResult_Failure) of the activex task itself.

So, if what you are trying to do is be able to pass the date result value back so it can be used elsewhere in the package, then use a global. Create the package level global and assign the value to it from the script. Somehting like this:

DTSGlobalVariables("RunDate").Value = setRunDate(new Date);


You can then grab it from other tasks easily. However, you do need to make sure your script also has an entry point. From that entry point you would call the code listed above and then set the status of the task so the package could continue:

function Main()
{
DTSGlobalVariables("DateValue").Value = setRunDate(new Date);
return DTSTaskExecResult_Success;
}


See what I mean? I just pasted your code into a DTS activex task and added the entry point Main function as listed above and it all worked fine.
[Reply][Quote]
Valeda
Posts: 15
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 12:51 PM
fiogf49gjkf0d
Hi Ryan,
First of all, thanks so much for your reply. It's nice to have someone with experience available when you need them.

I made the changes you suggested, but DTS is giving me an error on the DTSGlobalVariables line. Here is the code again:

//**********************************************************************
// Java ActiveX Script
//************************************************************************
function Main() {
var runDate;
var dateHoliday;
var today;
var d;
var runDay;
var runDt;

// Set the rundate to todays date minus 1
today = new Date();
runDate = new Date(today - 1);
runDay = (today.getDay() - 1);
runDt = new Date(runDate);

// Check to see if the new rundate is a weekend or holiday date
checkWeekendDate(runDate, runDay);
runDt = new Date(runDate);
runDate = (runDt.getMonth() + 1) + "/";
runDate += runDt.getDate() + "/";
runDate += runDt.getYear();
checkHoliday(runDate, dateHoliday);
if (dateHoliday == "y") {
checkWeekendDate(runDate,runDay);
}
DTSGlobalVariables("runDate").Value = setRunDate(new Date);
return DTSTaskExecResult_Success;
}

function checkWeekendDate(runDate, runDay) {
// If rundate is Saturday(6) or Sunday(0), set it to Friday
if (runDay == 6) {
runDate = (new Date(runDt) - 1);
runDay = runDay - 1;
} else {
if (runDay == 0){
runDate = (new Date(runDt) - 2);
runDay = runDay - 1;
}
}
return runDate, runDay;
}

function checkHoliday(runDate, runDay) {
var memorialDay = new Date('5/29/2006');
var julyFourth = new Date('7/4/2006');
var laborDay = new Date('9/4/2006');
var thanksgivingDay = new Date('11/23/2006');
var dayAftThanksgiving = new Date('11/24/2006');
var Christmas = new Date('12/25/2006');
var newYearsDay = new Date('1/1/2007');
dateHoliday = 'n';

// If rundate is one of these holidays, set it back 1 day
if (runDate == memorialDay || runDate == julyFourth || runDate == laborDay || runDate == thanksgivingDay || runDate == Christmas || runDate == newYearsDay) {
runDate = (new Date(runDt) - 1);
runDay = runDay - 1;
runDt = new Date(runDate);
dateHoliday = 'y';
} else {
// If rundate is the day after Thanksgiving, set it back 2 days
if (runDate == dayAftThanksgiving) {
runDate = (new Date(runDt) - 2);
runDay = runDay - 2;
runDt = new Date(runDate);
dateHoliday = 'y';
}
}
return runDate, runDay;
}
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 12:56 PM
fiogf49gjkf0d
What exactly is the error? Have you created a global in your package called "runDate" (and what data type is it)?
[Reply][Quote]
Valeda
Posts: 15
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 1:17 PM
fiogf49gjkf0d
I set up a global variable "runDate". It is type string. It will not let me change it to Date. Also, I am not sure of a couple of things. I changed the function name from setRunDate to Main. And I changed the DTSGlobalVariables statement to read:

DTSGlobalVariables("runDate").Value = Date(new runDate);

Receiving - "Object doesn't support this action" error from the above line.

Thanks for your patience and attentiveness.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 1:28 PM
fiogf49gjkf0d
Well, I can't see what you have now, but paste this code into your activex task and all should be working:

//**********************************************************************
// Java ActiveX Script
//************************************************************************

function Main()
{
var runDate;
var dateHoliday;
var today;
var d;
var runDay;
var runDt;

// Set the rundate to todays date minus 1
today = new Date();
runDate = new Date(today - 1);
runDay = (today.getDay() - 1);
runDt = new Date(runDate);

// Check to see if the new rundate is a weekend or holiday date
checkWeekendDate(runDate, runDay);
runDt = new Date(runDate);
runDate = (runDt.getMonth() + 1) + "/";
runDate += runDt.getDate() + "/";
runDate += runDt.getYear();
checkHoliday(runDate, dateHoliday);
if (dateHoliday == "y") {
checkWeekendDate(runDate,runDay);
}
DTSGlobalVariables("runDate").Value = runDate;
return DTSTaskExecResult_Success;

}

function checkWeekendDate(runDate, runDay) {

// If rundate is Saturday(6) or Sunday(0), set it to Friday
if (runDay == 6) {
runDate = (new Date(runDt) - 1);
runDay = runDay - 1;
} else {
if (runDay == 0){
runDate = (new Date(runDt) - 2);
runDay = runDay - 1;
}
}
return runDate, runDay;
}

function checkHoliday(runDate, runDay) {

var memorialDay = new Date('5/29/2006');
var julyFourth = new Date('7/4/2006');
var laborDay = new Date('9/4/2006');
var thanksgivingDay = new Date('11/23/2006');
var dayAftThanksgiving = new Date('11/24/2006');
var Christmas = new Date('12/25/2006');
var newYearsDay = new Date('1/1/2007');
dateHoliday = 'n';

// If rundate is one of these holidays, set it back 1 day
if (runDate == memorialDay || runDate == julyFourth || runDate == laborDay || runDate == thanksgivingDay || runDate == Christmas || runDate == newYearsDay) {
runDate = (new Date(runDt) - 1);
runDay = runDay - 1;
runDt = new Date(runDate);
dateHoliday = 'y';
} else {
// If rundate is the day after Thanksgiving, set it back 2 days
if (runDate == dayAftThanksgiving) {
runDate = (new Date(runDt) - 2);
runDay = runDay - 2;
runDt = new Date(runDate);
dateHoliday = 'y';
}
}
return runDate, runDay;
}


See what I mean?
[Reply][Quote]
Valeda
Posts: 15
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 1:39 PM
fiogf49gjkf0d
I LOVE YOU!!! Are you married? Just kidding. Thanks soooooo much.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Need activex helpYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Jul 06 1:41 PM
fiogf49gjkf0d
Quote:
Originally posted by Valeda

I LOVE YOU!!! Are you married? Just kidding. Thanks soooooo much.


Hehe. v.funny.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 5/3/2024 2:53:30 AM