Previous Topic: schedGroup Macro—Specify an Event Group

Next Topic: Access Export/Import

The setSchedEvents() JavaScript Function

The setSchedEvents() JavaScript function creates events in the schedule. Modify this function when you want to view any new group objects. The predefined group objects appear by default.

CA SDM calls setSchedEvents() once for each object (change order or knowledge document) selected by the schedule search filter. The function creates events for the object by calling a second function, schedEvent(), and passing the group ID, start date, and end date of the event.

The function can create any number of events (including zero) for an object. The default setSchedEvents() function for the Change Calendar (list_chgsched.htmpl) creates one event for each change order and groups change orders by change type. This function is coded as follows:

1.	function setSchedEvents( chg )
2.	{
3.	var grpnum;
4.	switch( chg["chgtype"] - 0 ) {
5.		case 100: grpnum = schedGroup_std;  break;
6.		case 300: grpnum = schedGroup_emer; break;
7.		default:  grpnum = schedGroup_norm; break;
8.	}
9.	chg.schedEvent( grpnum, chg["sched_start_date"], chg["sched_end_date"] );
10.	}

The case parameter specifies the change type ID. To list the case IDs, see Create a Change Type.

The function has a single argument of a JavaScript object containing the attributes specified by schedAttr macros. The switch statement in lines 4-8 examines the chgtype attribute of the change order, and assigns the appropriate group number from one of the schedGroup_xxxx variables defined by previous schedGroup macros. On line 9, it calls the schedEvent() function to create an event in the schedule, passing the group number previously assigned and the schedule start and end dates. The dates are available in the argument object because they were specified in earlier schedAttr macros.