Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Employee
alduet
Posts: 888
Country: USA
Message 11 of 19 (1,782 Views)

Re: Using ACT Framework with PHP via COM Interop ?

 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....

Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 12 of 19 (1,756 Views)

Re: Using ACT Framework with PHP via COM Interop ?

[ Edited ]

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[0];    // which should give me the first (and here the only) Stage object found above. EDIT : I meant '$stages[0]' not '$stages->[0]'.

 

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 :

 

echo $stage->Name;

 

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.

 

print_r($actFramework->StageManager->ActiveProcesses);   // which should print an array of 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 ?

Message Edited by kr123456 on 06-24-2010 06:53 AM
Message Edited by kr123456 on 06-24-2010 11:46 PM
Please use plain text.
Employee
alduet
Posts: 888
Country: USA
Message 13 of 19 (1,726 Views)

Re: Using ACT Framework with PHP via COM Interop ?

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.

 

 

Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 14 of 19 (1,707 Views)

Re: Using ACT Framework with PHP via COM Interop ?

[ Edited ]

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[0]->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.

 

Kevin

Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 15 of 19 (1,699 Views)

Re: Using ACT Framework with PHP via COM Interop ?

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("opp name", 0, $theGoodStage, $closeDate, false);
$newOpp->Update();


$newProduct = $actFramework->Products->OpportunityProductManager->CreateCustomEntity(); // doesn't work

 

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...

 

Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 16 of 19 (1,642 Views)

Re: Using ACT Framework with PHP via COM Interop ?

[ Edited ]

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.

Please use plain text.
Employee
alduet
Posts: 888
Country: USA
Message 17 of 19 (1,638 Views)

Re: Using ACT Framework with PHP via COM Interop ?

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.

Allen Duet
Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 18 of 19 (1,472 Views)

Re: Using ACT Framework with PHP via COM Interop ?

[ Edited ]

Hello,

 

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 ?

 

Thanks you.

Please use plain text.
Tuned Listener
kr123456
Posts: 25
Country: France
Message 19 of 19 (1,441 Views)

Re: Using ACT Framework with PHP via COM Interop ?

Hi again,

Sorry to double post, I couldn't find a way to edit the previous message.

I've just found a way to do what I wanted to do. For those who are interested, the details are explained there : http://community.act.com/t5/Developer-s-Forum/how-do-i-attach-documents-under-doucments-tab/m-p/8431...

See ya.

Kevin
Please use plain text.