I'm using the "create mapped object" feature in the Salesforce Mapped Objects form to push a contact message entry to Salesforce. The mapped entity fields are pre-filled when I enter the form but when I click on Push I get a white screen with the following error message:
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getEntityTypeId() on null in Drupal\salesforce_mapping\Plugin\Validation\Constraint\MappingEntityTypeConstraintValidator->validate() (line 19 of modules/salesforce/modules/salesforce_mapping/src/Plugin/Validation/Constraint/MappingEntityTypeConstraintValidator.php).
I tried turning off this validation constraint to see what would happen. If I do that I get the following error message on the form screen (doesn't break this time, though):
There are no entities matching " (1128)".
I'm not sure if these errors are related but it seems to me that the module is not able to get the info of the selected contact message entity in the form. I also notice that the target_id autocomplete field is trying to reference a comment type rather than the contact_message type. The path is something like:
data-autocomplete-path="/entity_reference_autocomplete/comment/default%3Acomment/qY_gILRPdqf5xqWeNOfwL7jcdPWi8bZ2nW6PBltLIik" ...
Comments
Comment #2
aaronbaumancan you upload the mapping you're using?
Comment #4
aaronbaumanI was able to recreate this issue by disabling javascript and pushing through an invalid entity-type / entity-id pair.
Previous commit eea87ec should fix, but please confirm.
Comment #5
cqbent commentedCan confirm that those changes fixed the issue with the first error, thanks. I was still getting the "no matching entities" warning so I did a little more digging and I think my issue has to do with the fact that I had the "subject" field disabled in the contact form. The subject field is used to reference the target contact entity in the mapping autocomplete field so my guess is that having this value null is causing the "no matching entities" issue (and probably the getEntityTypeId null issue as well). I reenabled the subject field and tested and its able to push successfully now.
Comment #6
kmeisthax commentedI'm working on a website in which we need to map contact form messages without a subject to SalesForce. The design of the form precludes the use of a subject (it won't be populated, we aren't collecting one, etc). Is it possible to change the autocomplete field so that it will accept entities without a title, perhaps with a preprocess hook?
Comment #7
aaronbaumanSeems like you could work around this by enabling push triggers for your mapping(s)?
I'm not sure what features are available for the entityreference autocomplete widget.
We're relying on the widget from core, so there may be an issue open for this in core.
Might want to check there first.
Comment #8
aaronbaumanFYI, not a core issue, but possibly a contact_storage issue: #3007082: Label is NULL for contact forms with Subject disabled
Comment #9
aaronbaumanComment #10
aaronbauman8.x is no longer supported