• pcave_jr
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 5
    Replies

Hello. I'm using the PHP SOAP toolkit with the partner api and I'm getting a strange response when running a query operation. I've been a long time user of the Enterprise WSDL and have not had any problems. Here is the simple query I'm running:

 

$result = $client->query("SELECT Id, Email, FirstName FROM Contact WHERE email in ('john.doe@example.com') ");

 And here is my result:

 

QueryResult Object
(
    [queryLocator] => 
    [done] => 1
    [records] => Array
        (
            [0] => stdClass Object
                (
                    [type] => Contact
                    [Id] => Array
                        (
                            [0] => 003G00000166xcxIAA
                            [1] => 003G00000166xcxIAA
                        )

                    [any] => john.doe@example.comJohn
                )

        )

    [size] => 1
    [pointer] => 0
    [sf:QueryResult:private] => SforcePartnerClient Object
...

 Does anyone know what is causing this? According to the samples the returned object should look something like this:

 

Array
(
    [0] => SObject Object
        (
            [type] => Account
            [fields] => stdClass Object
                (
                    [AccountNumber] => 12324312
                    [Name] => XYZ Account
                    [Website] => www.somewebsite.co.uk
                )

            [Id] => 0018000000Ll0VmAAJ
        )

 Any thoughts would be appreciated.

 

Is it possible to read the metadata of a report in Apex. I'm interested in being able to get the fields and conditions that have been assigned to a report programitcally.

 

Thanks,

Phillip

Is it possible to share an AES key between Salesforce and another application? I know there is the Crypto.generateAesKey() method, but I can't use that key in a PHP application to decrypt the data later. Is it possible to generate my own AES key from a string, then use that string as the AES key in both applications?

How do I check if a valid Contact is returned from a query like this in Apex.

 

Contact o = [SELECT c.Id, Email, LastName, FirstName, MailingCity, HomePhone, MailingState, MailingStreet, MailingPostalCode, AccountId, Source_Code__c, Drupal_User_Id__c FROM Contact c WHERE c.Email = :n.Email AND c.Id != :n.Id limit 1];

 

How do I check to see if o is a populate Contact object.

Do I need to pass a special value to set a picklist to 'none' when updating an object through the API? I've tried passing an empty string and it ends up setting the field to a 0.


Thanks,

Phillip

I have a custom object with a Contact lookup field. Is it possible to make this field required? It would need to be required through both the API and the Salesforce.com interface. Is this only possible with a trigger?

 

Thanks,

Phillip 

I'm using the leadDuplicatePreventer from the force platform cookbook to prevent duplicate emails. I've altered it to use the contact object instead of the lead object and it will not pass test coverage.

 

// Seed the database with some leads, and make sure they can // be bulk inserted successfully. Contact contact1 = new Contact(LastName='Test1', Email='test1@duptest.com'); Contact contact2 = new Contact(LastName='Test2', Email='test4@duptest.com'); Contact contact3 = new Contact(LastName='Test3', Email='test5@duptest.com'); Contact[] contacts = new Contact[] {contact1, contact2, contact3}; insert contacts; contact2.Email = 'test2@duptest.com'; contact3.Email = 'test3@duptest.com'; update contacts;

 

It fails on the update call that changes the originally inserted contact records even though they are not duplicates.

 

Does anyone know why this would happen? I understand most of the code in the duplicatePreventer class except for the System.Trigger.oldMap part.

 

Thanks,

Phillip

Does anyone have a RegEx to check for valid Salesforce Ids? I'm working on an integration project and need to validate values going into a reference field.

 

Thanks,

Phillip

I'm pretty new to salesforce so I was wondering if the following is possible. When a new contact is being created, is it possible to use some custom fields on that contact object to generate a new account and then relate the contact to it. I'm guessing this could be done using an Apex trigger. If anyone has any pointers or sample code, I would apprecaite it.

 

Thanks,

Phillip

I'm not the resident PHP developer, but our resource in-house has had the following issue:

 

We tried to upgrade our system from the Salesforce Partner PHP toolkit v11 to the latest v20.

 

However, we started experiencing some very strange results as soon as we switched to the new libraries. To confirm, we kept all the old working queries as is, so the issue is not with how we query or manipulate the data. The issue is that what Salesforce returns using the v20 toolkit is radically different and looks corrupt.  

 

We can switch the libraries back and forward (old and new) to produce the results below.

 

V11 returned the Object like:

 

SObject Object
(
    [type] => PricebookEntry
    [fields] => SimpleXMLElement Object
        (
            [UnitPrice] => 8.04
            [CurrencyIsoCode] => GBP
        )
    [sobjects] => Array
        (
            [0] => SObject Object
                (
                    [type] => Product2
                    [fields] => SimpleXMLElement Object
                        (
                            [Carbon_Database_id__c] => 12.0
                            [Id] => 01t20000000iTW4AAM
                            [Name] => Big River Salmon Creek Forestry
                            [Family] => Carbon Instruments
                            [IsActive] => true
                        )

                    [Id] => 01t20000000iTW4AAM
                )
            [1] => SObject Object
                (
                    [type] => Pricebook2
                    [fields] => SimpleXMLElement Object
                        (
                            [Name] => 3) >= 5
                            [IsActive] => true
                        )
                )
        )
)

 

V20 returned the Object like:

 

stdClass Object
(
    [type] => PricebookEntry
    [Id] => 
    [any] => Array
        (
            [Product2] => stdClass Object
                (
                    [type] => Product2
                    [Id] => Array
                        (
                            [0] => 01t20000000iTW4AAM
                            [1] => 01t20000000iTW4AAM
                        )
                    [any] => <sf:Carbon_Database_id__c>12.0</sf:Carbon_Database_id__c><sf:Id>01t20000000iTW4AAM</sf:Id><sf:Name>Big River Salmon Creek Forestry</sf:Name><sf:Family>Carbon Instruments</sf:Family><sf:IsActive>true</sf:IsActive>
                )
            [Pricebook2] => stdClass Object
                (
                    [type] => Pricebook2
                    [Id] => 
                    [any] => <sf:Name>3) &gt;= 5
                )
            [0] => <sf:UnitPrice>8.04</sf:UnitPrice><sf:CurrencyIsoCode>GBP</sf:CurrencyIsoCode>
        )
)

 

Notice how unstructured and a mess this is, it has jumbled all the relevant data into these <sf: tags.

 

This issue occurred on the first Query, here are the bones of that part:

 

$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);

foreach ($queryResult->records as $record) {
print_r($record);

 

Does anybody know why the change from Version 13 to version 20 might have caused this change?

Is it possible to read the metadata of a report in Apex. I'm interested in being able to get the fields and conditions that have been assigned to a report programitcally.

 

Thanks,

Phillip

How do I check if a valid Contact is returned from a query like this in Apex.

 

Contact o = [SELECT c.Id, Email, LastName, FirstName, MailingCity, HomePhone, MailingState, MailingStreet, MailingPostalCode, AccountId, Source_Code__c, Drupal_User_Id__c FROM Contact c WHERE c.Email = :n.Email AND c.Id != :n.Id limit 1];

 

How do I check to see if o is a populate Contact object.

Hello,

 

I am trying to encrypt and decrypt a password using the Crypto class.

 

 

 try{
     Blob cryptoKey = Crypto.generateAesKey(128);
    	 Blob data = Blob.valueOf(weUserRec.password__c);
      Blob encryptedData = Crypto.encryptWithManagedIV('AES128', cryptoKey, data);
    
      Blob decrypt = Crypto.decryptWithManagedIV('AES128', cryptoKey, data);
 
  }catch(Exception e){
     System.debug(e.getMessage());
 }

 

The above is throwing an exception with message "Invalid initialization vector. Must be 16 bytes" (InvalidParameterValue).


Since the SF provided Managed IV methods are used here (the code is almost exactly like the sample), why does it throw this error?

Thanks.

  • November 24, 2010
  • Like
  • 0

I have a custom object with a Contact lookup field. Is it possible to make this field required? It would need to be required through both the API and the Salesforce.com interface. Is this only possible with a trigger?

 

Thanks,

Phillip