I'm using the iCalUS function from cflib.org which uses cfscript to generate iCal for a calendar. It is possible that an activity has more then one location. The locations are coming from a different table, so I want to use a Valuelist to get a comma separated list.
My code:
<cfquery datasource="#application.dsn#" name="getEvents">
select project.project_id,omschrijving, project.naam, project.start,project.eind,room, meeting_url
from project, lp_booking, lp_locaties
where export = <cfqueryparam value="1" cfsqltype="cf_sql_bit">
and keuren is null
and project.datum >= <cfqueryparam value="#createODBCDate(Now())#" cfsqltype="cf_sql_date">
and lp_locaties.room_id = lp_booking.room_id
and lp_booking.project_id = project.project_id
order by project.datum
</cfquery>
<cfscript>
eventStr = StructNew();
function iCalUS(stEvent) {
var vCal = "";
var CRLF=chr(13)&chr(10);
var date_now = Now();
vCal = vCal & writeoutput('BEGIN:VCALENDAR'& CRLF);
vCal = vCal & writeoutput('VERSION:2.0'& CRLF);
vCal = vCal & writeoutput('PRODID:Name'& CRLF);
vCal = vCal & writeoutput('X-WR-CALNAME:SOMENAME' CRLF);
vCal = vCal & writeoutput('CALSCALE:GREGORIAN'& CRLF);
vCal = vCal & writeoutput('METHOD:PUBLISH'& CRLF);
for(i=1; i LTE getEvents.RecordCount; i=i+1){
vCal = vCal & writeoutput('BEGIN:VEVENT'& CRLF);
vCal = vCal & writeoutput('SUMMARY:'&getEvents.naam[i]& CRLF);
vCal = vCal & writeoutput('UID:'&getEvents.project_id[i]& CRLF);
vCal = vCal & writeoutput('SEQUENCE:0'& CRLF);
vCal = vCal & writeoutput('STATUS:CONFIRMED'& CRLF);
vCal = vCal & writeoutput('TRANSP:OPAQUE'& CRLF);
vCal = vCal & writeoutput('DTSTART;TZID=Europe/Amsterdam:'&reReplace(getEvents.start[i],"[-:]","","all")& CRLF);
vCal = vCal & writeoutput('DTEND;TZID=Europe/Amsterdam:'&reReplace(getEvents.eind[i],"[-:]","","all")& CRLF);
vCal = vCal & writeoutput('DTSTAMP:'&reReplace(getEvents.start[i],"[-:]","","all")& CRLF);
vCal = vCal & writeoutput('LOCATION:'&getEvents.room[i]& CRLF);
vCal = vCal & writeoutput('DESCRIPTION:'&getEvents.omschrijving[i]&'\n\n\n'&getEvents.meeting_url[i]& CRLF);
vCal = vCal & writeoutput('URL:'&application.webUrl& CRLF);
vCal = vCal & writeoutput('END:VEVENT'& CRLF);
}
vCal = vCal & writeoutput('END:VCALENDAR'& CRLF);
return Trim(vCal);
}
</cfscript>
<cfcontent type="text/calendar" reset="Yes">
<cfheader name="Content-Disposition" value="inline; filename=churchbookAgenda.ics"> <cfoutput>#iCalUS(eventStr)#</cfoutput>`
Now I want to use:
vCal = vCal & writeoutput('LOCATION:'&valuelist(getEvents.room[i])& CRLF);
When I do I get an error: variable [SomeRoomName] doesn't exist. When I remove the [i] it works, but I get all the locations found in the query.
vCal = vCal & writeoutput('LOCATION:'&valuelist(getEvents.room)& CRLF);