Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    Locating the Me Card
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Apprentice
Posted
Is there some way to script finding the Me card? I have tried many things. This seems to be the closest:
document := (NSApplication sharedApplication) firstDayliteDocument.
objectContext := document objectContext.
qual := BDKeyValueQualifier keyValueQualifierWithKey:'name' operatorSelector:#isEqualTo: value:'Me'.
users := objectContext objectsForEntityNamed:'User' matchingQualifier:qual.
users == nil ifTrue:
[
	NSNumber numberWithBool:0.
]
ifFalse:
[
	((users objectAtIndex:0) valueForKeyPath:'rawRow') description.
].

but it doesn't find me. If I use this:
document := (NSApplication sharedApplication) firstDayliteDocument.
objectContext := document objectContext.
users := objectContext objectsForEntityNamed:'User'.
users name.

I do get an array that includes the Me contact as the last object. Is it always the last object? I have tried iterating through the users returned in this second method and comparing their name to 'Me' but that never resolves as true.

Thanks,
Jon Nathan
 
Posts: 5 | Registered: November 06, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
'Me' is the current user in Daylite.
You can get the current user by one of two techniques.

You can ask the document or the objectContext for the currentUser.

document := (NSApplication sharedApplication) firstDayliteDocument.

meUser := document currentUser.
meContact := meUser contact.


Since a user is a person, the person's details are in a contact object that is attached to the user object.

Hope this makes sense.
 
Posts: 891 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
Perfect. Thanks!
 
Posts: 5 | Registered: November 06, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Scripting    Locating the Me Card

© Copyright 2006 Marketcircle Inc. All rights reserved.