Looping and cfscript
ColdFusionI came up with some ColdFusion code yesterday that I thought I'd share with you all. This might not be revolutionary to many people but it's pretty dang cool to me.
Without going into too much detail I need a way to add time off to a production database for all users when a manager entered in a holiday. It'd wouldn't be much fun if the manager had to enter in Christmas time off for each of his or her employees. So what I did was create some code that 1) called a CFC to get all of the employees and then 2) loop through the query of employees and add the submitted holiday time for each.
Like I said this might not be significant to most, but it's cool to me and it's all <cfscript> which I find cool.
First, execute a cfc to get a list of employees
//returns a list of team members to add for this holiday
qSubTeam = application.gatewayTeam.getSubTeam (
subTeam_ID = 17,
teamLead = 0
);
Second, loop though the query getting the next employee's id. The cool part here is how I retrieve the UUID field. By using the current row, intRow, I am able to locate the appropriate UUID by referencing the record set as an array.
// loop over the days from start to end and add them to the production log
for (
intRow = 1;
intRow LTE qSubTeam.recordCount;
intRow = (intRow + 1)
)
{
//get the employee to add holiday for
variables.uuid = qSubTeam['UUID'][intRow];
//do some other stuff here to add holiday for this employee...
}
Anyway, just thought I'd share. Pretty damn cool to me. If you would like to see more of the code, it's available over at codeShare.
Good Day!
Ryan





Loading....