Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Building Reports and Print Layouts    Selected Contact w/ f-script
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
AJC
Apprentice
Posted
I'm building a report and would like to access the selected contact via f-script. Is there a way to do this?

--
andrew
 
Posts: 8 | Registered: June 01, 2007Reply With QuoteEdit or Delete MessageReport This Post
AJC
Apprentice
Posted Hide Post
OK. No responses yet. Here's what I've found searching the forums. You can reference the last selected object using this code:

objects := (document firstMainWindowController) selectedObjects.
object := objects lastObject.
objectName := object name.
sys log: objectName.

However, when this is run through the report engine, it fails. That is to say that it can be run successfully as a Daylite script (.dlscript) but not via the report engine. The Console log prints this:

5/21/08 10:37:56 PM Daylite[3098] Report Script execution error -- stack follows:
(
)
error: undefined identifier "document"
objects := (document firstMainWindowController) selectedObjects.
object := objects lastObject.
studentName := object name.
sys log:  studentName.

So, my thoughts are that the reference to "document firstMainWindowController" is where the problem lies. Any thoughts?

--
andrew
 
Posts: 8 | Registered: June 01, 2007Reply With QuoteEdit or Delete MessageReport This Post
AJC
Apprentice
Posted Hide Post
Alright. I think I've solved this and wanted to post in case it would help anyone else. The reference to "document firstMainWindowController) was the problem. You must first reference the Daylite document.

document := (NSApplication sharedApplication) firstDayliteDocument.
objects := (document firstMainWindowController) selectedObjects.
object := objects lastObject.
contactName := object name.
repData := element reportData.
repData setObject:contactName forKey:'selectedContact'.

This code is run as a pre-extraction script on the report. The last two lines store a reference to the value in the reportData element with the key 'selectedContact'. You are then able to pull this information into reports dynamically using the following snippet.

(element enclosingReportLayout) valueForKeyPath: 'reportData.selectedContact'.

For what it's worth. Obviously, the user should have a contact selected in the source list before running this report.

--
andrew
 
Posts: 8 | Registered: June 01, 2007Reply With QuoteEdit or Delete MessageReport This Post
Marketcircle Team
Picture of Oscar
Posted Hide Post
Why not use a print layout?
 
Posts: 495 | Location: Toronto | Registered: February 20, 2007Reply 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    Selected Contact w/ f-script

© Copyright 2006 Marketcircle Inc. All rights reserved.