Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Building Reports and Print Layouts    resolving KeyPath token(?) in F-Script token
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Journeyman
Posted
What is the general syntax for getting the value of a keypath element into an f-script (token)?

Assume I have a table drawing data from a form that consists of field A and field B.

Field A = parent.reportData.object.A
Field B = parent.reportData.object.B

So, how do you refer to these values? Is there something along the lines of

x := value(Field A)
since the f-script would already know the context it's in --

Or do you do something along the lines of

x := objectContext some.path.to.field A ?

Or neither?

So assume Field A and Field B are numbers, and I wanted the sum, just how would the f-script look?


here's hoping...
 
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
The syntax would be:

x := reportElement valueForKeyPath:'parent.reportData.object'.

reportElement is the element that contains the token.

Not knowing what you are planning to do, I'm assuming you want to make this behave like a spreadsheet cell. There is one problem - if that cell's value is derived (calculated), then it may not be resolved by the time your script runs. The safer route is get the values directly from the object(s) and then do your calculation as opposed to depending on the result of a cell.


BTW: reportData is a dictionary so you can use it to store variable using something like this:

data := reportElement valueForKeyPath:'parent.reportData'.

data setObject:'my variable' forKey:'theThing'.

The following keys are reserved: object, objects, name, index, groupBy.

If you use this, you have to be careful in which order you use this (think of the tree). I think we have to add some mechanism at the top level so you can setup commonly used, calculated, variables.
 
Posts: 875 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Thank you so much, AJ. I'm really close to this I think, but still not getting it.

I should just be able to show the value for the field in this case by the following, right?

x := reportElement valueForKeyPath:'parent.reportData.object.A'.
x

But nuthin'. I also tried
x := reportElement valueForKeyPath:'parent.reportData.object'.
x.A

which is a long-shot I'm sure, but thought maybe I was confused regarding the path (which I probably am).

Regarding storing variables- that is very cool. I just have to get the really easy stuff out of the way first!

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
There are 3 variables here:

1) 'parent.reportData' could be 'parent.parent.reportData'. The positioning is relative, so you have to make sure you know where to look.

2) it could be 'object' or 'objects'. 'objects' is an array of items as opposed to a single item (such as a contact).

3) the 'A' after 'object' is not valid. If 'object' was a contact, then something like 'firstname' would be valid.

Hopefully this helps you navigate the tree to get your data.
 
Posts: 875 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
quote:
Originally posted by AJ:

reportElement is the element that contains the token.



Okay, I'm starting to feel really stupid, but I just don't get this- What element are we talking about? The Data Row? The Table? The field itself? How do you actually refer to this element within a dynamic text?

Let's say I've got a report, 1 strip, 1 table, table is a query from Project. I want to show Extra Field1. I can add this as a normal key token with
parent.reportData.object.extra1
Now I want to show this exact same value using a F-Script token:

x := extra1 getValueForKeyPath:'parent.reportData.object'.

-Nope. undefined identifier "extra1"

If this was outside a dynamic text, wouldn't it probably be like

x := Project getValueForKeyPath:'parent.reportData.object.extra1'. ? Since extra1 is a key of Project?

This doesn't work either within the dynamic text tho.

So how the heck do you determine what reportElement is?

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
Ah - good question - which element?

The best way to explain this is too look at a diagram we have in the Report Engine doc. Page 18 in the June 11 Draft.

The whole system is a tree with branches and leafs. Each branch and leaf is an element.

In this case, the report element is the dynamic text element.
 
Posts: 875 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
Eric,

I have an embarassing admission - I make a mistake earlier - the variable for the report element is not 'reportElement' - it is 'element'.

I think I owe you a few beers.

Sorry!!
 
Posts: 875 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
quote:
Originally posted by Eric O'Connell:

Now I want to show this exact same value using a F-Script token:

x := extra1 getValueForKeyPath:'parent.reportData.object'.

-Nope. undefined identifier "extra1"

If this was outside a dynamic text, wouldn't it probably be like

x := Project getValueForKeyPath:'parent.reportData.object.extra1'. ? Since extra1 is a key of Project?

So how the heck do you determine what reportElement is?

Thanks!


So if you want to get the extra1 field in the f-script you do this:

x := element valueForKeyPath:'parent.reportData.object.extra1'.

This is assuming you are in a dynamic text element inside a row inside a table.

To get the whole project object, it would be this:

proj := element valueForKeyPath:'parent.reportData.object'.

To get the array (list) of projects, it would be:

projects := element valueForKeyPath:'parent.parent.reportData.objects'.

It is parent.parent because the projects are on the table and not on the row.


Damn - I feel bad about that reportElement mistake. Sorry again.
 
Posts: 875 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Wow, that makes a world of difference...

Thank you ~ I thought I was losing it there. Perhaps when things settle down we could get a "Basic functions with F-Script" page or two added in the Report docs or something.

It looks like element always returns a string? No big deal, I figured out coercion, just curious.

Never thought that half my time with DayLite would be spent in X-Code's documentation! We're talking industrial strength contact management now! smile
 
Posts: 96 | Location: San Francisco | Registered: June 22, 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    resolving KeyPath token(?) in F-Script token

© Copyright 2006 Marketcircle Inc. All rights reserved.