06-23-2010 09:26 AM
is there another way to get contacts by name, company or email ?
Well - you could create an OLEDB connection and get the contact records using a SQL statement - there's examples of this in some of the code examples.
It is a bit puzzling as to how you can instantiate a class with arguments....
06-24-2010 06:38 AM - edited 06-24-2010 11:46 PM
Okay Allen, thanks for your answer, I'll try this out, I think it'll work better than struggling with COM...
By the way, I have another issue with the COM ; I'd like to create an opportunity, but before calling the "CreateOpportunity" method from the ActFramework, I have to initialize some variables, in particular the stage of the opportunity. I just wrote these lines :
$stages = $actFramework->StageManager->GetStages("Initial Communication"); // which should give me a Stage (Stage array) with the one I want inside.
$stage = $stages; // which should give me the first (and here the only) Stage object found above. EDIT : I meant '$stages' not '$stages->'.
These lines don't throw any error, but I found out that the "$stage" variable isn't a Stage object. For example, when I try to access any of it's properties like this :
It throws me this error : Uncaught exception 'com_exception' with message 'this variant has no properties'.
I also tried select the Processes first, then get the right Stage of the right Process.
But it only prints 'variant Object' instead of printing my 4 processes that I have in my database.
Which let me think the COM Interop have some issues with returning arrays.
edit : $stage = $stages->First(); // doesn't work neither, tells me the 'First()' function isn't defined...
Does someone have already experienced this ? Or am I wrong with some syntax rule ?
06-24-2010 05:02 PM
It's hard for me to conceptually follow so I'm installing EasyPHP and I'll take a look at this this weekend -trying to get a create history, create opp example going.
06-25-2010 01:17 AM - edited 06-25-2010 01:19 AM
I thank you very much for always taking the time to help us out, but by groping along I finally found a way to access the stages of the array. I use the for each loop to browse it.
Even if it's not very pretty, it works :
$stages = $actFramework->StageManager->GetStages("My new opportunity Stage"); // searching by Name
echo $stages->Name; // doesn't work
foreach ($stages as $oneStage) // this way I can access every Stage object in the array
if($oneStage->Process->Name == "My process") // if the stage make part of the right process
$theGoodStage = $oneStage;
echo $theGoodStage->Name; // actually working, this is definitely a Stage object
I didn't found any other way to access content of arrays returned by COM objects, but I'm okay with this one. I'll surely come back with another surprise, it keeps on getting better and better...
Anyway thank you for your answers and your help Allen.
06-25-2010 06:33 AM
Well, that was quick, I'm stuck again...
I'd now like to add products to the opportunity I just created, but I can't create a new product :
$newOpp = $actFramework->Opportunities->CreateOpportunity_2(
$newProduct = $actFramework->Products->OpportunityProductManager
The line just above throws me a "Warning: main() [function.main]: variant->zval: conversion from 0xd ret=-1"
Seems like a conversion didn't worked. So I proceeded step by step like this :
$products = $actFramework->Products; // OK
$oppPrManager = $products->OpportunityProductManager; // line which throws the warning above
$newProduct = $oppPrManager->CreateCustomEntity(); // doesn't work
The last line throws me a "Fatal error: Call to a member function CreateCustomEntity() on a non-object" which seems to confirm the warning...
I'm starting to despair !
Although, the OpportunityProductManager doesn't seem to be an array or another strange type which could mess up with COM Interop...
06-29-2010 07:54 AM - edited 06-29-2010 07:58 AM
Sorry for the triple posting, but I finally managed to get the whole thing working.
The last problem was because COM Interop doesn't handle generic classes like the OpportunityProductManager one.
So I just delegated the instanciation of opportunity products (and other problematic things) to a .NET dll I've created (in C#).
It contains a class with one default constructor (which doesn't requires any parameter, so I can instanciate it with COM), and some simple methods filled with the job COM can't do (definitely looks like a "wrapping" system).
It actually works for numerous tasks, and I think this will resolve a lot of problems in the future.
Again, thanks for your presence and your help on this serious forum.
06-29-2010 08:10 AM
I was having the same problem with generic classes. Thanks for the info, that's a good approach (basically a wrapper class).
Thanks again for posting here.
07-26-2010 08:32 AM - edited 07-26-2010 08:34 AM
It's been a while, but once again I need your help...
This time I'd like to programatically add a document (or at least a note/history with a pdf attached with) to a contact. In my dummy test C# project, everything's just fine, I use the CreateHistory method of the ActFramework object and the pdf file is well attached to the history.
But when I try to delegate it to my famous dll (because of some COM restrictions, like a static method to get an empty guid, and COM cannot support it like discovered above), I can't manage to make it work.
My PHP code calls the good method as usual via the COM object, but this time I get an error message which says : 'Unable to insert a history' (or a note, because I also tried this way).
I heard on some others posts that it was because of some user rights or something... If someone knows more, could you help me and explain me how to fix this ?
07-29-2010 07:32 AM