0

How would i populate an Opportunity custom field? using iSDK

everytime i try to add one, it populates the Contact custom field and not the one on opportunities

the name of my custom field in opportunity is message_form, database is messageform

here is my relevant code

$oppor = array(
'Email'=>'greatest@mail.com',
'_messageform'=>'lorem ipsum dolo'
);
//action ID is set to add opportunity
$actionId = 224;

$newCon = $app->addCon($oppor);
//run an action set on the contact
$stat = $app->runAS($newCon, $actionId);
tomexsans
  • 4,454
  • 4
  • 33
  • 49
  • Is this not what you want: https://github.com/infusionsoft/PHP-iSDK/blob/9525dc4aca8f9657719d54d43eea1043c5bd1abe/src/isdk.php#L895 ? If not, I may not be understanding. – rnevius Jan 26 '15 at 21:30

1 Answers1

1

The problem is that you are using the $app->addCon method, which adds a contact. You have to have an existing Contact, and then create an opportunity record using the correct method that is linked to the contact record, and put the _messageform field in the opportunity record, not the contact record.

FYI, you cannot run action sets on opportunities, just contacts. Personally, I dislike the iSdk. We use this sdk here at Novak Solutions (we wrote it): https://github.com/novaksolutions/infusionsoft-php-sdk It's really object oriented and if you use and IDE that has auto-complete it is a dream to use.

Flexo
  • 87,323
  • 22
  • 191
  • 272
Joey Novak
  • 19
  • 1
  • Yup the isdk sure is not nice, and their second version is the same. I cannot seem to find a sampe on how to add a Opportunity? can you direct me on that using your sdk? – tomexsans Jan 27 '15 at 12:46
  • We didn't have a sample, but I just added it to our examples page: https://github.com/novaksolutions/infusionsoft-php-sdk/wiki/Examples – Joey Novak Jan 28 '15 at 17:54