Forums
Extending Daylite
Building Reports and Print Layouts
Getting data from a relationship|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Apprentice |
Hi All
I am trying to build a report based on opportunities, I would like to get a specific contact based on their relationship to the opportunity, but I am struggling to find a good method to achieve this. I have an array of all the contacts linked to the opportunity, but I have no idea how to only show the contact in the specific relationship I am interested in. Can anyone point me in the right direction? Thanks Meyric |
||
|
|
Apprentice |
Hi All
So I have managed to solve this. You can run a f-script to prodcue dynamic text, I cobbled together a script to iterate through my array of contacts and pull out the relevant ones. I actually used opportunities 'Contact Roles' to find the contact in a specified role. Script is here if you need a starting point: "get all roles for an opportunity" roles := element valueForKeyPath:'parent.reportData.object.contactRoles'. "set up a loop" rolesCount := roles count. i := 0. "for every role check what the role is and if it is the right one, set the value of keyPerson" keyPerson := 'None Specified'. [ i < rolesCount ] whileTrue: [ role := roles objectAtIndex:i. roleName := role valueForKeyPath:'roleType.name'. ( roleName isEqualToString:'string of role' ) ifTrue: [ keyPerson := role valueForKeyPath:'contact.name'. ]. i := i + 1. ]. "return the value" keyPerson. Mec |
|||
|
|
Marketcircle Team |
Thank you for the forum and script contribution Mec.
We really appreciate it. |
|||
|
|
Apprentice |
Thanks for posting this. I'm able to get it to work, sort of. It will only display one contact from the list. I'm expecting it to display all of the contacts that match the criteria. So if I have three contacts that match the criteria, I want it to display all three contacts, not just the first one in the list. I've banged my head against this for over two hours, but can't seem to make any progress. I have been able to verify the script is getting all of the roles for an opportunity, so I know that part is working. Any help on this would be greatly appreciated. Thanks!
|
|||
|
|
Apprentice |
Sorry for the nOOb question but how can I put this script in the dynamic text box to generate the result?
I can't seem to generate the script tag that I have seen in other reports and just pasting in the text doesn't work |
|||
|
|
Apprentice |
Right so you just have to look a little harder in the dynamic text box window!
Anyway I got the script tag and pasted in the script but I get this error when i try to run the report: any thoughts? The Block Inspector returns this error [ i < rolesCount ] error: argument 1 of method "<" is nil, an instance of NSNumber was expected |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|
Forums
Extending Daylite
Building Reports and Print Layouts
Getting data from a relationship
