The creation of the OpportunityContactRole node is essentially a hack to work around an issue with salesforce_api_fieldmap_export_create(). I'd like to get rid of it, since it is confusing, adds to the code of the uc_sf_order_export() function, and clutters the node table. To do this may require #993766: Add native support for mapping of "foreign keys" for already mapped objects.
I could just manually add the $order->salesforce->sfid to an $ocr object in uc_sf_order_export(), but that might be fragile and more of a hack. Thoughts?
Comments
Comment #1
longwave+1 - I think fieldmaps are overkill here, as this is just a many-many mapping between two Salesforce objects I cannot see any extra data you would want to associate with this data. Adding code to handle this directly in uc_sf_order_export() seems like a useful simplification of the existing code rather than a hack.
Comment #2
EvanDonovan commented@longwave: I agree with you, and when I get around to doing another release of this code, I believe that will be included. Unfortunately, this has become quite a busy month for me in terms of paying work, and I don't think I would have time to do further development on this module this month. (Its code is a bit of a mess, and I think things would get worse before they would get better.)
If you were interested in getting commit access as a co-maintainer, I would be willing to offer that to you, since you are much more experienced with Ubercart development than I am. If you were to contact me via my contact form on d.o., I could give you a fairly detailed walkthrough of the code. I offer this simply because I don't want to hold you up on your projects due to the current state of the dev version of this module.
Comment #3
EvanDonovan commentedI actually think that it might still make sense to map the OpportunityContactRole in some cases. But I will do this in the way that I handled mapping accounts (in the as-yet-uncommitted uc_sf_account module) - i.e., the mapping will be from the order object directly.
Eventually, uc_sf_account might make this feature not as important since Opportunity->Account linkage is more standard in Salesforce than Opportunity->OpportunityContactRole->Contact (at least in the cases when Opportunity->Account is missing).
Comment #4
EvanDonovan commentedBumping priority, since this is probably the most important task prior to another alpha.
Comment #5
EvanDonovan commentedI decided to release another alpha prior to making this change, since it has the potential to break the module, and I want people to be able to take advantage of the other features that have been added and bug fixes that have been made.
I will probably release the alpha in the next few days, if no bug reports come in on the latest dev.
When I do make this change, I will be moving all the OCR-related code out of uc_sf_order_export, and putting it in a separate module. Then there can be Conditional Actions integration with that, so the OCR information will export separately.
At least at first the ability to export a matching OCR for each Opportunity Line Item will not be present, since that would make the code more complex.
Comment #6
EvanDonovan commentedThe reason why I wanted to make this still mappable is that there is at least one valid use case: when you have multiple OpportunityContactRoles being exported for the same order (i.e., via uc_sf_account), and you need to have a different Role value for each in Salesforce (presumably using a fixed value field to export the role).
Additionally, you could add any arbitrary additional fields to the OpportunityContactRole object in Salesforce, so I want to still be able to account for that.
Comment #7
EvanDonovan commentedComment #8
EvanDonovan commentedThis is now in dev (not in the just now tagged alpha4). Testers welcome.
Now there is a separate module for OCR export based on the order data. It's just the code from uc_sf_order refactored out, essentially, but without a node type to support it.
Any problems, please post a follow-up issue.