SBX - Search With Button

SBX - Forum Post Title

Retrieving altKey from online crm using Web API

Microsoft Dynamics CRM Forum

lenin bhargav asked a question on 15 May 2019 8:07 AM

Question Status

Suggested Answer

Hi

I have a requirement that, i need to retrieve altkey(s) of entities (or a particular entity) using web API. By using query

GET [Organization URI]/api/data/v9.0/accounts

iam able to get records of account but not altkey, if i use metadata query also iam unable to fetch it.

Please help me out here, to retrieve altkey(s) of entity(s).

Reply
Suggested Answer

Hi

You have to use the Keys attribute of EntityMetadata

docs.microsoft.com/.../microsoft.xrm.sdk.metadata.entitymetadata.keys

Reply
lenin bhargavs responded on 16 May 2019 1:53 AM

Thanks for the Response.

If i use query     /api/data/v9.0/EntityKeyDefinitions     web API is throwing an error like

Resource not found for the segment 'EntityKeyDefinitions'.

If i use /api/data/v9.0/EntityMetadata also iam getting same error.

EntityDefinitions is working but in that there is no property for getting Keys.


Can you please send the query that works fine for Retrieving Alternate Keys.

 

Reply
lenin bhargavs responded on 16 May 2019 5:17 AM

If i use Query

/api/data/v9.1/$metadata#Keys/$Entity

iam able to fetch field names for which i have created alternate keys

example

Annotation Term="OData.Community.Keys.V1.AlternateKeys">

<Collection>

<Record Type="OData.Community.Keys.V1.AlternateKey">

<PropertyValue Property="Key">

<Collection>

<Record Type="OData.Community.Keys.V1.PropertyRef">

<PropertyValue Property="Alias" String="name"/>

<PropertyValue Property="Name" PropertyPath="name"/>

</Record>

</Collection>

</PropertyValue>

</Record>

</Collection>

</Annotation>.

But my requirement is to get the name of alternate key example new_account , new_(name of alternate key user have given),

Please help me out here

Reply
Suggested Answer

Hi

You have to use the Keys attribute of EntityMetadata

docs.microsoft.com/.../microsoft.xrm.sdk.metadata.entitymetadata.keys

Reply

SBX - Two Col Forum

SBX - Migrated JS