Hi there,
I've got a question and I hope you can help me a little bit - that would be great :)

As Victor released this module I started developing my first own module. It is my objective to give the user the option to view, insert and update cases. In detail this is what I have:
- created a new module called salesforce_cases
- module creats a new content type "salesforce_cases"
- module extends admin/settings/salesforce via form_alter() in order to give the admin the option to administer the module
- module extends admin/content/salesforce via hook_menu() in order to view the cases (but I don't think I need this page)

This is what I want:
SSU/User
------------
- when a new Self Service Portal user (SSU) is created (based on an existing contact) a new Drupal user is generated
- I think we can make use of the existing database tables "users" and "salesforce_users" to store the ContactId, Email and Username
- problem: it is not possible to retrieve the password of the SSU -> so I have to set a new password, store it in the user table and send (mail) it to the user
- user should have the possibility to update his/her profile data

CASES
---------
- user logs in at Drupal website and creates a new node (type "salesforce_cases")
- node is stored in Drupal and a new case is generated in Salesforce
- add a form with several fields (like case name, status, priority and some computed fields like date etc.) to create and update cases (updates will be displayed in Salesforce as well)
- changes in Salesforce will be displayed in Drupal
- display cases via view module (I'd like to give the user the option to sort the entries etc.)

Right now I don't know what's the best way to handle all of the above mentioned functions. How can we handle the problem with the Self Service Portal users? Do you have any better idea how to cope with the cases? Is it a good idea having a new content type? Should we make use of CCK? It would be great if you come up with some ideas etc.!

Thank you.
Bjoern

Comments

bjacob’s picture

StatusFileSize
new1.35 KB

I thought it is a good idea to upload the code I've already got. I know it's nothing special but I hope somebody is willing to share some ideas. Would be great :)

eojthebrave’s picture

StatusFileSize
new4.47 KB

As a proof of concept I've put together this module based on the ideas, and code from this thread. http://drupal.org/node/192605

I don't mean to undermine the work that you've done in anyway, but this allowed me to test and refine the code in my salesforce_sync_api.inc file and make it work for more than just accounts. If you want to try this module out you'll need to download the code from here http://drupal.org/node/192605#comment-635341, and at a minimum put the salesforce_sync_api.inc file from that .tgz into your salesforce directory.

Note that I haven't tested this out to much yet, but in the testing I did do everything seems to be working.

bjacob’s picture

Hey eojthebrave,
you've put a lot of work in this module. I'm impressed! It's no problem for me that you didn't use my code. It's the first time in my life that I'm trying to create a new module...
What have I done so far:
- I've read all your comments
- installed your salesforce_case module, cck, content, text, date api, date etc.
- placed salesforce_sync_api.inc in the folder /sites/all/modules/salesforce/
- went to /admin/settings/salesforce/cases and synchronized the data model
- got the following message:

warning: require_once(sites/all/modules/salesforce/salesforce_sync_api.inc) [function.require-once]: failed to open stream: No such file or directory in /sites/all/modules/salesforce_case/salesforce_case.module on line 311.

    * Importing/Updating of the Case object from Salesforce was successfull
    * 13 fields inserted, 0 fields skipped

- went to node/add/salesforce-case and created a case --> case was both saved in Drupal and Salesforce

Next steps:
- test the module, want to find out why this warning showed up
- test the limiting SOQL (I don't need all fields in Drupal)
- find a way to hide fields (maybe according to their role --> CKK?)
- display cases with the help of views
- find a way to solve this problem: "when a new Self Service Portal user (SSU) is created (based on an existing contact) a new Drupal user is generated"
- I think it is a good idea to give the user the option to decide in which case a new user is created in Drupal
- so a checkbox would be great to say "only create new user in Drupal when Self Service Portal user"
- that means I just have to adjust the SQL query ... we'll see...
- solve problem: admin/settings/salesforce/cases/queue --> Page not found

I'll keep you informed about my further steps.

eojthebrave’s picture

That error message is because the module couldn't find the salesforce_sync_api.inc file. You probably want to take all the files out of the salesforce_case directory and put them right into your salesforce directory. Should be something like this.

salesforce/
salesforce/includes/
salesforce/salesforce.module
salesforce/salesforce_sync_api.inc
salesforce/salesforce_case.module
salesforce/salesforce_case.info
salesforce/salesforce_case.install
... etc

Guess I should probably add a check to make sure that the .inc file is loaded properly. -

You'll probably also need to re-run the "model update" script in Settings >> Salesforce >> Salesforce Cases to get things working right. Let me know how it goes.

bjacob’s picture

Thanks you for your reply. What did I do:
- moved the files to salesforce/
- re-installed the salesforce_case module
- re-run the "model update"
No error message came up. So this should be okay. But one thing happend. When I uninstalled the module the content type salesforce_case was deleted. I.e. all of my cases were deleted in Drupal. The good thing is they are still available in Salesforce. Right now I'm not sure. Does your module also import cases from Drupal? I've to test it...

Edit: One thing occured: In {salesforce_field_map} the mapping was still available. But in {content_type_salesforce_case} no mapped fields showed up. I had to delete the entries in {salesforce_field_map} manually (with PHPMyAdmin) and started the "model update" again. Now everythin works fine.

Edit: Tested it several times. No case was imported from Drupal... mmh. Have to check the source code.

eojthebrave’s picture

Edit: Tested it several times. No case was imported from Drupal... mmh. Have to check the source code.

When you create a new case in Drupal it is NOT being inserted into salesforce?

If you want to try and re-install the module completely here's what you need to do.

Uninstall salesforce_case.module

Drop the {salesforce_field_map} table and the {salesforce_sync_log} table.

Remove the row corresponding to the salesforce_case.module in {system}, otherwise the .isntall file will not be run when you enable the module again.

Finally, make sure that the table {content_type_salesforce_case} doesn't exist, and that you remove all the rows with type_name="salesforce_case" from {node_field_instance} table, and all rows with field_name that starts with "field_case_*" from {node_field}.

This should give you a clean slate to start with, you can then re-install the module, and run the "model import" script.

I'm guessing that because the the module couldn't find all the necessary files the first time the 'model updater' was run that you've ended up with some partial/corrupted data in your database. Hopefully this will take care of that.

Guess I should probably write an un-installer for this thing sometime too.

bjacob’s picture

I've tested your module and I've found a problem regarding hook_access()

What did I do?
- went to access control: authenticated user are allowed to "create new salesforce case" and "edit own salesforce case"
- in a second browser logged in as a "normal" user
- created case
- viewed case --> problem: user can't edit the node
- I've changed to salesforce_case.module code from

} else if (user_access('edit own salesforce case') && $user->account_id == $node->field_account_id[0]['value']) {

to

} else if (user_access('edit own salesforce case') && ($user->uid == $node->uid)) {

and it works very well. Is this the right solution? Why is your solution not working in this case?

Thanks for any comment.

bjacob’s picture

I've done some more testing and styling of the case module. Here is what I've found:

  1. A general problem: In Salesforce I've created a field of the type "Picklist (Multi-Select)". Somehow this field is not created when I synchronize the data model.
  2. I was wondering why field_case_casenumber is not synchronized. In function salesforce_case_nodeapi -> case 'insert ' there is a comment saying it will be synchronized with the next cron run. So far it's not synchronized i.e. the field remains saying "Not Assigned".
  3. We have to make sure that the Salesforce field "Contact Name" is not empty. I.e. the cornjob has to submit the name (full name) of the Durpal user who created the case. As soon as the "Contact Name" is available in Salesforce the field "Account Name" won't be empty anymore (I'm not sure but when I manually assigned the Contact Name the field Account Name was filled out).
  4. It's not enough to synchronize the case. We have to make sure that comments can be synchronized as well. In addition events have to be created when needed.

And one question. In Salesforce I've created a field of the type "Formula (Text)". The data model synchronization worked very well i.e. the field was created in Drupal. But the value is not synchronized. Am I right that fields of this type are computed "on demand" and can't be synchronized?

As you can see I've got a lot of questions. I think some of the described problems are more general and can be implemented in the salesforce account module. Some other problems are only related to the case module and I think nobody will come up with a solution. I will give my best and try to solve the problems...

flymint’s picture

Assigned: Unassigned » flymint
Category: feature » bug

Hello,

I working with bjacob with the salesforce module. Last time I had some trouble synchonizing cases. There wasn't any synchronizing cases from salesforce to drupal. I'm a newbie in salesforce and newbie in drupal, so it takes a lot of time locating the error in salesforce_sync_api.inc. The $obj_fields in function _salesforce_sync_get_object_data contains the 'Name', but there isn#t any field name in salesforce Cases. The field is called 'Subject'. So, while the 'Name' is hard included to SQL string the reply was every time empty for synchronisation a case.
I fixed the problem with a if-clause:

	if ($type == "Case") {
		$obj_fields = array('Subject');
	} else {
		$obj_fields = array('Name');
	}

I mean, that isn't the best solution. I will post the problem in other thread too, because I can't understand, why the Name ist hard coded. This will only a report, for you, fixing the synchronization salesforce cases.

bjacob’s picture

Assigned: flymint » Unassigned
Category: bug » feature

We've found another problem. Right now we've modified the case module in order to synch comments which were created in Salesforce. in Salesforce the corresponding database table is named "casecomment". There are two fields which have to be synchronized: "LastModifiedByID" an "LastModifiedDate". And there it happens: both fields are created and mapped but both of them have the same name "field_casecomment_LastModi".

I think we have to change the function (_salesforce_sync_make_field in salesforce_sync_api.inc) which is responsible for creating the fields with the help of CCK. I've noticed the problem on a different project as well. There I created the fields manually and the field names were truncated too.

eojthebrave’s picture

This update addresses and fixes the following problems.

Synchronization of booleans via salesforce_sync_api.inc - http://drupal.org/node/211541
Should work now. Uses the CCK option field type to create a checkbox for the field

Fixes this problem with hardcoded values in the salesforce_sync_api - http://drupal.org/node/211138
Thanks bjacob and flymint for tracking this one down.

Fixes a problem with long field names in Salesforce resulting in duplicate field names in Drupal. - http://drupal.org/node/193235#comment-708407
Field names are now checked for uniqueness before creation and will have numbers appended to them if needed.
ie. ) field_case_really_long_field, field_case_really_long_fiel1, field_case_really_long_fiel2 and so on. If anyone has suggestions for a better naming convention I'm open.

I've created a patch that should apply against the version of the salesforce_sync_api.inc file from here http://drupal.org/node/192605#comment-635341, and the patch to salesforce_cases.modules should apply to the most recent version of the module from this post. http://drupal.org/node/193235#comment-643550

I've also attached a .tgz with complete versions of all the files.

Note that if you patch salesforce_sync_api.inc that salesforce_case.module will be broken until you patch/update it as well.

Let me know if you have questions about getting this working with your existing code and I'll see if I can help.

bjacob’s picture

Hi there,

we are moving on with the integration of the functions we need for our recent project and we've found another "problem". We have to synchronize the ContactID. Therefore I've tried to create the field with the help of the field mapping function but it didn't show up. Therefore we changed the code of salesforce_sync_api.inc. We have to use the field "reference" in order to map the ID field:

change from

'reference' => false, // not really sure how to deal with these, or if we even really need to.

to

'reference' => array('field_widget_type' 	=> 'text-text',
'widget_type'  => 'text'),

After synchronizing the data model four new fields were created: Contact ID, Account ID, Asset ID, Owner ID. I don't know if it's the proper way to handle reference fields. I will check your post where you've described how to find out the handling of certain fields (when there's more time). But right now it seams that handling it as text is okay, at least for me because I don't want to have it linked.

TimAlsop’s picture

It looks like no changes have been made to this module since Feb 2008 (almost 2 years ago) so I am wondering if anybody is planning to update the module to work with the latest Salesforce API module (at http://drupal.org/project/salesforce) ?

TimAlsop’s picture

Another question - once the cases from salesforce are in drupal in the salesforce_cases object, what module is used to allow users to manage their own cases and add comments ? Is this done using webform only or is something else required to allow users to see list of cases, and add comments, view comments, add attachments etc.

aaronbauman’s picture