There are actually two bugs here but it turns out the functionality isn't being used anyway, so it doesn't cause any problems.

Issue 1:
The $client is being used before it is even defined. Line 360 of the salesforcewebform.module(function salesforcewebform_process):

$all_fields['OWNERID'] = $client->userId;

$client isn't set until line 397:

	// Process of logging on and getting a salesforce.com session
	$client = new SforcePartnerClient();

This results in $client->userId always being null.

Which leads to Issue #2, looking throught the Toolkit SoapClient Code SforcePartnerClient object doesn't have a property for userId. Which means even if you fix Issue #1 it will still always return null.

Setting the userId is not necessary as the OwnerId field is defaultedOnCreate, so it sets the owner to whomever made the API call. (whomever is setup in the Admin SalesForceWebForm settings becomes the owner of anything submitted through the SalesForceWebForm)

The code could be changed to a client call to getUserInfo () to retrieve the userId, but the userId returned will be the same userId that the defaultedOnCreate automatically puts in there, so it would be a wasted call.

I suppose if owner seperation is required, functionality would have to be put in to query all the User objects, match it to the user who is assigned to the form (not the user submitting the form, but possible the creator of the form, or a specifically defined owner of all form submissions) and then set the OwnerId to that user's retrieved ownerId.

The fix for this would be to remove setting the OwnerId.

Comments

chriscalip’s picture

Assigned: Unassigned » chriscalip
chriscalip’s picture

I cant improve 2.x branch I keep on getting error messages whenever I commit to the 2.x branch. Having said that I am withdrawing my time and efforts in the 2.x branch.

Here is an example:

quickstart@qs091:~/websites/gr.dev/sites/all/modules/salesforcewebform$ git diff
diff --git a/salesforcewebform.module b/salesforcewebform.module
index 444bbee..765358e 100644
--- a/salesforcewebform.module
+++ b/salesforcewebform.module
@@ -345,7 +345,6 @@ function salesforcewebform_process($node, $form, $form_state) {
}
}
$sid = empty($form_values['submitted_tree']['webformsid__c']) ? _salesforcewebform_generate_sid() : $form_values['submitted_tree']['webformsid__c'];
- $all_fields['OWNERID'] = $client->userId;
$submitted = $form_values['submitted'];

foreach($submission as $keyid=>$keyval) {
quickstart@qs091:~/websites/gr.dev/sites/all/modules/salesforcewebform$ git commit -am "Issue #1092344 by chriscalip : minor bug fix remove reference to a non-existent object at that point in time";
[6.x-2.x eb2d970] Issue #1092344 by chriscalip : minor bug fix remove reference to a non-existent object at that point in time
1 files changed, 0 insertions(+), 1 deletions(-)
quickstart@qs091:~/websites/gr.dev/sites/all/modules/salesforcewebform$ git push -u origin 6.x-2.x

chriscalip’s picture

Assigned: chriscalip » Unassigned
obsidiandesign’s picture

Status: Active » Fixed

Fixed in 6.x-2.x version as of this evening.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.