3

I want to create Task with 'Related To' (WhatId) field, where the type is 'Product'. But salesforce always says that malformed_id.

$fields = array ( 'STATUS' => 'IN PROGRESS', 'PRIORITY' => 'NORMAL', 'WhoId' => 'xxxx', 'SUBJECT' => 'My Subject', 'WhatId' => 'MXD, // Existing Product code 'Type' => 'Download' );

In case, if i gave AccountId. it works well, but need to insert 'Product Code'.

-- Update:

I found the solution:

I get the WhatId from 'Product2' table.

$product_response = $Connection->query("SELECT Id from Product2 WHERE ProductCode='CUSTOMPCODE'"); $data = (array) $product_response->records; $whatid = $data[0]->Id[0];

after getting $whatid, then submitted to sales-force:

$fields = array ( 'STATUS' => 'IN PROGRESS', 'PRIORITY' => 'NORMAL', 'WhoId' => 'xxxx', 'WhatId' => $whatid, 'SUBJECT' => 'My Subject', 'WhatId' => 'MXD, // Existing Product code 'Type' => 'Download' );

it works well!

Thanks for who helped.

1
  • You could put your solution as an answer. You're allowed to answer your own questions. Jun 22 '16 at 9:21
1

You can't use the "Product Code" field when associating the task to the product directly. It must be a unique 15- or 18-character identifier. If you are attempting to use an "upsert" command, you could use an External ID. See the documentation for upsert for more information.

-1

WhatID can be ID of a related Account, Opportunity, Campaign, Case, or custom object. Please find the link

1
  • 1
    It can also be a product, as well, even though the documentation doesn't explicitly state this.
    – sfdcfox
    Dec 17 '13 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.