Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to match with date fields? #40

Open
Mike-Cleaver-LB opened this issue Nov 10, 2024 · 4 comments
Open

How to match with date fields? #40

Mike-Cleaver-LB opened this issue Nov 10, 2024 · 4 comments

Comments

@Mike-Cleaver-LB
Copy link

Hi team, I am trying to add DOB as a date field and use it for matching.
I have set up a custom DOB field on the user object, and the query references it (several times, the client wants a 3 of 5 match)
but the error is "Invalid bind expression type of String for column of type Date" It is passing the date yyyy-mm-dd into the query successfully by my understanding, but presumably it is in the wrong format? I don't see anyway to set the format on a date input

I know how to do it with some apex, but I don't have that option here. Any ideas would be welcome!

The log message is as follows

Form Values: {Birthdate=1987-12-10, Email=[mike.cleaver+dobtest@.....[trimmed].... password=HIDDEN}
There was a problem executing the specific query in the Custom Query property. Query used:

SELECT id FROM Account WHERE (firstname = :firstName AND lastname = :lastName AND personemail = :email) or...[trimmed]... or(firstname = :firstName AND lastname = :lastName and PersonBirthdate = :Birthdate) or ...[trimmed]... or (personemail = :email AND phone = :MobilePhone and PersonBirthdate = :Birthdate).

Error: Invalid bind expression type of String for column of type Date
@jlowe-SFDC
Copy link
Collaborator

Hi @Mike-Cleaver-LB - This should work fine. I'm using a date match for my client. How is the date field configured? It is a date on the user object and in the form?

My example so you can compare configuration:

Log record:
Searching for record with query:SELECT Id,AccountId FROM Case WHERE Crime_Ref_Number__c = :Crime_Ref_Number__c AND Contact_Date_of_Birth__c = :Contact_Date_of_Birth__c AND (ContactEmail = :Email OR Mobile_Phone_Unformatted__c = :Mobile_Phone_Unformatted__c) LIMIT 1.

Submitted Values: {Contact_Date_of_Birth__c=2001-01-01, Crime_Ref_Number__c=21240000219, Email=[email protected], FirstName=JACK, LastName=TEST, Mobile_Phone_Unformatted__c=07448411354, confirmPassword=HIDDEN, password=HIDDEN}

Form setup:
image

Field in SF:
image

Let me know and might be able to identify if there is an issue to fix.

@Mike-Cleaver-LB
Copy link
Author

So the value I'm comparing to in the record is a date

it's called personBirtdate on the account object (we're using person accounts)
image

it's called birthdate on the user record
image

image
is how the metadata is setup for this field.

I might just temporarily to one check on date only and see if that behaves differently

@Mike-Cleaver-LB
Copy link
Author

I corrected my metadata to be the user api name for birthdate and the error is similar

...
Username valid.
An error occurred whilst trying to update the User Object:Illegal assignment from String to Date
Form Inputs: {Birthdate__c=1987-12-10,

@jlowe-SFDC
Copy link
Collaborator

jlowe-SFDC commented Nov 18, 2024

Hi @Mike-Cleaver-LB - I believe I've spotted the issue. I was able to reproduce it in my customer org based on what you provided above. I'll fix this in v1.9 which is due for release soon.

In the code, where it maps the form fields to the user, the component takes everything as a string and doesn't convert to the correct data type for the field.

Currently, where the component queries for an existing Person Account/Business Account or creates a new Person Account/Business Account the data type conversion works fine as long as the custom field doesn't exist on the user as well. As soon as it does, it goes bang!

There is a call to a function called "convertFormDataToCorrectDataType" which does the conversion, which is not called when checking existence for fields on the User object. So I believe the fix is as follows:

image

Is there a possibility you could push the code from the feature/passwordless branch in a sandbox and test out your query against the new version before I release it please? The fix seems to work on my end.

Alternatively, you can get at a beta version to install it here:https://login.salesforce.com/packaging/installPackage.apexp?p0=04tWU0000003g5x - however this does come with a caveat that once in beta, you will break the upgrade path until you manually uninstall and re-install a major release version again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants