Title: Re: Setting Contact Categories via Ascript
On 12/11/2000 7:27 PM, "Paul Berkowitz" <[EMAIL PROTECTED]> wrote:

On 12/11/00 6:27 PM, "Michael Scheurer" <[EMAIL PROTECTED]> wrote:

I want to assign some categories to selected contacts via a script but for some reason it's not working.

The reason is that you’re not doing it right. I’m not sure how or were you got the idea that ‘properties’ is the way to set ‘category’.

Here is the snippet:

tell application "Microsoft Entourage"
    set theContacts to selection
   repeat with i in the theContacts
    set properties of i to {category:"Personal"}
    end repeat
end
tell

it returns the following:

   -->    Microsoft Entourage got an error: Can't set properties of contact id 920 to {category:"Personal"}.

In theory this should do it...

Whose theory would that be?

        
set category of i to {category:"Personal"}

Actually I think he means:

       set category of i to {category "Personal"}

(no colon)

i, being a contact (if you’ve selected some contacts, that is) has about 53 properties. You can’t set all of them to a list of categories. What you want to set here the contact’s ‘category’ property. So do it.

You usually use ‘properties’ only when making a new element, and are specifying a number of (non-default) properties all at once, e.g.:

    make new contact with properties {name:"Silly Billy", home address:{street address:"123 Flop Street", city:"Imaginary", state:"CA"}, age:123, category:{category "Personal"}}


Neither of those two conditions apply in your script.


Actually, you can also use it to set multiple properties at once like:

        set the properties of contact 1 to {first name: “Dan”, last name: “Crevier”}

It’s a bit faster than doing it with two commands because it only has to send one AppleEvent. You learn something new every day :-)

Dan

Reply via email to