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

Problem with types when using retrieveMultiple in typescript #279

Open
lawsl opened this issue Sep 8, 2022 · 3 comments
Open

Problem with types when using retrieveMultiple in typescript #279

lawsl opened this issue Sep 8, 2022 · 3 comments

Comments

@lawsl
Copy link

lawsl commented Sep 8, 2022

Describe the bug
When trying to filter solutions based on related accountid and name of the other solutions on the related account.
accounid comes out as a string but the related account requires a guid, and the only way I could make it works was casting accountId as any which is not optimal

Expected behavior
I think that either accountid should be a guid or the filter should expect a string

Screenshots

image
Environment

@magesoe
Copy link
Collaborator

magesoe commented Sep 8, 2022

Have you tried using the Filter.makeGuid function to turn a string into a guid?

@lawsl
Copy link
Author

lawsl commented Sep 8, 2022

yes, the filter.makeguid made a guid formatted like (guid'{xxxxxxxx-xx-xxxxxx}) which didn't work with filter.equals
the ppm_account_guid and accountid comes out excactly the same but can't be compared because one is a string and one is a guid

@skovlund
Copy link
Contributor

skovlund commented Sep 9, 2022

As magesoe says Filter.makeGuid should solve this for you. When Dynamics 365 resolves your filters, it ignores braces '{}' around your guids as well as casing.

I made the below test (with a hardcoded guid from a trial environment), and even though the primary contact have to match all four different values, the query still finds an account.

let account = await XrmQuery
    .retrieveMultiple(x => x.accounts)
    .filter(x => Filter.equals(x.primarycontactid_guid,  "2C03653C-39CD-EC11-A7B5-000D3A471234" as any))
    .filter(x => Filter.equals(x.primarycontactid_guid, "{2C03653C-39cd-EC11-A7B5-000D3A471234}" as any))
    .filter(x => Filter.equals(x.primarycontactid_guid,  "2c03653c-39cd-ec11-a7b5-000d3a471234" as any))
    .filter(x => Filter.equals(x.primarycontactid_guid, "{2c03653c-39cd-ec11-a7b5-000d3a471234}" as any))
    .promiseFirst();

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

3 participants