Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Building Reports and Print Layouts    Multiple Qualifiers in script filter
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Journeyman
Posted
Ok, I've got a 1-qualifier f-script working; for example:

qual := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'2'.

And I'm now wondering how you can filter on multiple qualifiers: Say I wanted to find 'typeCode' isLike:'2' OR 'typeCode' isLike:'3'

Or more usefully, to find if completeDate (in a Task here) falls within a user-supplied date range.

So do you write separate qualifiers and somehow mix them in the matchingQualifier expression? Or write one qualifier along the lines of an SQl query? My experiments haven't hit on it yet..

Also, the Dev guide notes that more types of qualifers can be found in the DBQualifier (or BDQualifier) headers- I'm not finding this..

Thank you!
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
What you need to do is group them into an BDAndQualifier or BDOrQualifier.

qual1 := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'2'.
qual2 := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'3'.

qualifiers := NSArray arrayWithObjects:qual1, qual2, nil.

orQual = (BDOrQualifier alloc) initWithQualifierArray:qualifier.

(I'll need to get back to you about the date question)

As far as the source is concerned, look in the Developer Kit. There you will find a folder called 'Qualifier' and in there, there are both 'Documentation' and 'Source' folders.

Hope this helps.
 
Posts: 864 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Yes, this is incredibly helpful. I completely missed the Qualifier documentation- It still really helps to see a concrete example of course..

I would love to see an example of passing a date range to a filter if and when you get a chance- I foresee that coming up again and again..

Thank you AJ- I really appreciate all your help!
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
I'm not getting past an "end of command expected" syntax error on this now. I've got a couple of versions, neither currently successful:

Ver 1-

qual1 := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'2'.
qual2 := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'3'.

qualifiers := NSArray arrayWithObjects:qual1, qual2, nil.

zorQual := (BDOrQualifier alloc) initWithQualifierArray:qualifiers.
oc := objectContext objectsForEntityNamed:'Task' matchingQualifier:zorQual.
oc.

So that gives me the "End of command" error and no data returned, as does this other one I've been playing with, based on the Qualifier Docs:

Ver 2-

qual1 := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'2'.
qual2 := BDQualifier qualifierWhereValueOfKey:'typeCode' isLike:'3'.

orQual := BDOrQualifier initWithQualifiers:qual1, qual2, nil.

oc := objectContext objectsForEntityNamed:'Task' filteredArrayUsingQualifier:zorQual.
oc.

Any tips greatly appreciated~!
Thank you
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
Instead of:

qualifiers := NSArray arrayWithObjects:qual1, qual2, nil.

try:

qualifiers := {qual1, qual2}.
 
Posts: 5 | Registered: July 01, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Holy Cow!

I didn't expect the actual *inventor* of F-Script to answer- now that's service!

Yep, this works now. And I am very grateful. I'd love to hear your input on my date range question (ie, are there other options than isLike: ?)

Again, thank you so much Philippe. I'm super impressed..
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
Philippe was kind enough to show me SEL equivalent needed for the date range.

What you need to use is BDKeyValueQualifier.

myDate := NSCalendarDate calendarDate.

myDateQual := (((BDKeyValueQualifier alloc) initWithKey:'dueDate' operatorSelector: #isLessThan: value:myDate) autorelease).

Look in BDQualifier.h for the selectors to use (use the simple ones such as lessThan, greaterThan, avoid the compound ones such as isLessThanOrEqualTo.
 
Posts: 864 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Thank you AJ. This crash course is getting interesting. So I have spent some time with NSCalendarDate, and I'm wondering if there is a certain format that needs to be used.. The following returns all tasks, but doesn't throw an error- so I think it's a valid date in general, but not for the qualifier:

myDate := NSCalendarDate dateWithString:'Thursday, 6 July 2006' calendarFormat:'%A, %d %B %Y'.

myDateQual := (((BDKeyValueQualifier alloc) initWithKey:'completeDate' operatorSelector:#isGreaterThan: value:myDate) autorelease).

oc := objectContext objectsForEntityNamed:'Task' matchingQualifier:myDateQual.
oc.

(Ideally, the dateWithString value gets replaced with a user-input date at some point. Problem for another day).

I'm still not sure how this would apply to a date range though- I can say 'Find every task completed After such and such' or 'Find every task Before such and such' but it seems like there needs to be a mix between a BDAndQualifier and the BDKeyValueQualifier..

And is there an easy way to track variable values to the log? Something along the lines of
myLog := NSLog(myDate)

but in a way that works? razz

This is getting fun. Hope I'm not over-imposing..
Thanks!
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
You probably don't want to use that dateWithString method.

There are 2 ways you can do this:
Create a concrete date using the -initWithYear:month:day:hour:minute:second:timeZone: instance method

or...

use some additions I forgot to expose (sorry):

+ dateWithYear: month: weekOfMonth: dayOfWeek: hour: minute: second: timeZone:

+ dateWithYear: month: weekOfMonth: dayOfWeek:

+ dateWithCurrentHour

- dateByAddingYears:
- dateByAddingMonths:
- dateByAddingWeeks:
- dateByAddingDays:
- dateByAddingMinutes:
- dateByAddingSeconds:
- dateByAddingHours:
- dateByAddingHours: andMinutes:

- dateByStrippingTime
- dateByStrippingDate

- minutesSinceDate:
- daysSinceDate:
- monthsSinceDate:

- numberOfDaysInMonth

- minutesSinceBeginningOfDay

- isLaterThanCalendarDate:aDate
- isEarlierThanCalendarDate:aDate
- isSameCalendarDay:aDate
- isSameCalendarDayTime:aDate

- dateAsEndOfDay
- dateAsBeginningOfDay
- dateAsEndOfScheduleDay
- isEndOfScheduleDay


- nextDay
- previousDay
- dateAsBeginningOfMonth
- dateAsEndOfMonth
- lastDayOfMonth

remember the difference between the + and - methods (class and instance).

So to get a date 7 days from today, you do this:

now := NSCalendarDate calendarDate.

date := now dateByAddingDays:7.

To get the end of the day, you do this:

end := date dateAsEndOfDay.


Hope this helps!
 
Posts: 864 | Location: Toronto | Registered: May 03, 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  Building Reports and Print Layouts    Multiple Qualifiers in script filter

© Copyright 2006 Marketcircle Inc. All rights reserved.