You need to sign in to do that
Don't have an account?
Mrdini
More efficent PHP code?
Currently, I am in the process of reworking my web-to-lead script into a more efficent form that uses the Salesforce API.
However, I have a niggling feeling that I'm taking a fairly roundabout way of doing this code-wise, and as such, there could be a better way of doing this....
On a side-note, how would I assign to another owner without YET another query (in the event of this owner being inactive, or a queue). TIA!
$sf_query = "SELECT COUNT() from Contact WHERE email = '".$query['email']."'"; $queryResult = $mySforceConnection->query($sf_query); if(($queryResult->size) >= 1) { $sf_query = "SELECT id, Name, OwnerId from Contact WHERE email = '".$query['email']."'"; $queryResult = $mySforceConnection->query($sf_query); $sObject->WhoId= $record['0']->Id; $sObject->OwnerId = $record['0']-> OwnerId; $sObject->stuff = "Stuff" . . . $createResponse = $mySforceConnection->create(array($sObject), 'Task', $header);What I'm wondering is whether it's really necessary to do 2 queries, the first in order to check if an contact with that email exists, & the 2nd to retrieve that record. As far as I can tell, COUNT() must be in a query of its own, hence me asking...
On a side-note, how would I assign to another owner without YET another query (in the event of this owner being inactive, or a queue). TIA!
Park Walker (TAGL)
You do not really need the first query; just execute the second query and see if there is a result. If there is, you have what you want. As for the owner question, I'm afraid your stuck with another query unless you want to hard-code the alternate value if the assigned owner is a queue, and possibly two more if you want to know if the assigned owner is inactive.