returning record to automator workflow

There´s something with my code that I don´t understand. My automator action gets a few items as input and returns some of these items, if they meet some requirements, mostly if these items are of the requested classes.

This works fine for dates, ical events… but not with AS records. The resulting output of an record is an empty list.

The essence of the code is this:

repeat with myObject in processInput 
	if (class of myObject) is record then
		tell me to log "class: record"
		set returnIt to true
		set foundIt to true
	else
		-- ...
	end if
	If returnit is true then
		copy myObject to the end of Outputlist
		try
			tell me to log (class of myObject as text) & " " & (summary of myObject) & " included in OutputList"
		on error
			tell me to log "invalid class included in OutputList"
		end try
	end if
end repeat
return Outputlist

I have lots of logging everywhere and by testing the properties of the record I know that the object that is copied to the output list is valid. Nevertheless, in automator it shows up as empty list and is interpreted by following actions as such.

I tried everything I could think of like “contents of myObject” etc. - no change. But just now I changed the last log statement:

tell me to log (class of (last item of Outputlist) as text) & " " & (summary of (last item of Outputlist)) & " included in OutputList"

Now, the record is returned.
What is the magic that I don´t understand?

Are you sure there wasn’t something different between the records you were using? I would expect records where the labels are AS keywords (name, button returned, etc) to be returned as empty lists, but not records with user defined labels.

This is a very interesting hint. Indeed, AS keywords are part of the labels. To be precise, what I am trying to retrun are iCal events or: AS records that have the same properties as the events. So there are labels like “start date” etc.

Thus, I can treat both kinds of objects alike (because iCal has no class for recurring instances of an recurring event).

This also means that large parts of the script are wrapped inside tell application “iCal” blocks.

Since “magically it started to work”, however, the returned objects (one iCal event object + one AS record object) are displayed with the “utilities”-icon in Automator. I would expect the first item to be displayed with the iCal icon, the second item with an “empty” icon.

Even more, I don´t believe anymore that it is working correctly. Both items look too much alike (they should be the iCal event that initiates the recurrence + the record representing the recurring instance the next day) - the date values are identical. They are different only in one value: ‘seld’

Feeding another instance of the action with the result, results to items with redundant data, p.e. two items with twice the information. Nonetheless they are recognized by following actions as event and record. And thy have their diffent dates again.

So I have to admit that I don´t understand how to return data to automator and what automator is displaying at all. Somehow it works.(?) But what is happening??? I am confused.

The empty list is returned whenever I use “copy contents of myObject to …” But then, again, the event is displayed with the correct iCal icon. The very last data dump shows the automator results, when I use “set myObject to contents of myObject” before copying it to the Outputlist.

But first the data samples of the event and record that I use for testing step by step in the workflow:

a) returned by an old AS Studio Action (very nice and human-readable)

b) passed by the ASOC action I am currently working on.
Recognized as event and record. Note that I don´t change the values, all I do is copy and return them.
And please compare the dates. They should be different.

c) passed again by the same ASOC action.
Input again is recognized as event and record. Note the redundance in display. Dates all still the same.

d) passed to another ASOC action that exports them to text
The Input still is recognized as event and record. The dates are different, the result, overall, is fine.

And here the data sample with “contents of myObject”. The first result looks much more alike the old ASS action´s output, the second result is recognized as empty list.

Seems the issue is also triggered by the way I use the repeat loop:

repeat with itemNumber from 1 to (count of processInput)
    set myObject to item itemNumber of processInput
    copy myItem to the end of OutputList

preserves the iCal formatted result display in automator and changes my record into an empty list (it´s entry in OutputList), while

repeat with myObject in processInput
    copy myItem to the end of OutputList

returns all items with utilities icon and strange textual interpretation, but preserves the values of my record.

Double binding it, helps:

set itemNumber to 0
repeat with myObject in processInput
    set itemNumber to itemNumber + 1
    tell application "iCal"
        if class of myObject is event then
            copy item itemNumber of processInput to the end of OutputList
        else if class of myObject is record then
            copy myObject to the end of Outputlist
        end if
    end tell
end repeat

Still, I´d like to understand it. So far, my testing relies on an old ASS action to provide the input. Now I wonder, whether it behaves differently with input provided by an ASOC action.