Skip to main content

Notifications

Customer Service forum

CIF's getEntityMetadata API always returns plain object for Attributes

Posted on by 5

Hi, I am recently working on CIF but a problem troubles me a lot.

I'd like to make my own query statements to simulate the same behaviors of Search, since the param `$search` doesn't work for the returned result if I specified it and make `searchOnly` true in the API `searchAndOpenRecords`.

So, one thing I need to do is to find out these attributes that may be associated with searchText. For example, If searchText is a telephone number, then I need to know telephone1, telephone2, and mobilephone are the related attributes, so that I can make a query like `$filter=contains(telephone1, 'xxx')  or contains(telephone2, 'xxx') or contains(mobilephone, 'xxx')`.

It's easy to get metadata if I use OData, however, for CIF it's difficult. I tried to call `getEntityMetadata` by `const rawRes = await Microsoft.CIFramework.getEntityMetadata('account')`. The command was successfully executed, but in the returned object I found that 'Attributes' is always a plain object.

3872.cif_2D00_1.png

Could you help me with it? Is this a bug in CIF or a wrong operation I've done, if it's the latter, how can I do to achieve my purpose?

Thanks very much!

Categories:
  • Ruphi Profile Picture
    Ruphi 5 on at
    RE: CIF's getEntityMetadata API always returns plain object for Attributes

    Thank you so much @Henry Jammes. By the way, I'd like to make a further description for the issue. I've found that a request were successfully sent and responded when I inspected Network, from the responsive JSON data I could see that 'Attributes' is not an empty property. So it makes me confused, do some unexpected behaviors occur when CIF's API is converting the JSON data to API's returned results?

    And I can meet my requirements by using OData in the following way:

    async function getPhoneFields() {
    const baseUrl =
    `/api/data/v9.0/EntityDefinitions(LogicalName='contact')/Attributes/Microsoft.Dynamics.CRM.StringAttributeMetadata`
    const condition = '?$select=DisplayName,LogicalName,FormatName&$filter=IsSearchable eq true'
    const res = await fetch(`${baseUrl}${condition}`, new Headers({ credentials: true }))
    const data = await res.json()
    return data ? data.value : []
    }


  • Henry J. Profile Picture
    Henry J. 5,235 on at
    RE: CIF's getEntityMetadata API always returns plain object for Attributes

    Hi Ruphi,

    I've moved your post from the Unified Interface forum to the Customer Service one, more appropriate for Channel Integration Framework questions.

    Henry

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,297 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans