web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Retrieve entity metadata of MaxValue and MinValue for decimal field in CRM 2016

(0) ShareShare
ReportReport
Posted on by 164

Team,

I would like to retrieve “MinValue” & “MaxValue“ in the following query but I’m receiving following error message.

Example: "cel_amount" field data type is “decimal“ and it will accept (MinValue:0 & MaxValue:1000) only.

http:// / /api/data/v8.1/EntityDefinitions?$filter=EntitySetName eq cel_test&$expand=Attributes($select=LogicalName,AttributeType, MinValue ,MaxValue)

{ "error":{ "code":"","message":"Could not find a property named 'MaxValue' on type 'Microsoft.Dynamics.CRM.AttributeMetadata'.","innererror":{ "message":"Could not find a property named 'MaxValue' on type 'Microsoft.Dynamics.CRM.AttributeMetadata'.","type":"Microsoft.OData.Core.ODataException","stacktrace":" at Microsoft.OData.Core.UriParser.Parsers.SelectPathSegmentTokenBinder.ConvertNonTypeTokenToSegment(PathSegmentToken tokenIn, IEdmModel model, IEdmStructuredType edmType, ODataUriResolver resolver)\r\n at Microsoft.OData.Core.UriParser.Visitors.SelectPropertyVisitor.ProcessTokenAsPath(NonSystemToken tokenIn)\r\n at Microsoft.OData.Core.UriParser.Visitors.SelectPropertyVisitor.Visit(NonSystemToken tokenIn)\r\n at Microsoft.OData.Core.UriParser.Parsers.SelectBinder.Bind(SelectToken tokenIn)\r\n at Microsoft.OData.Core.UriParser.Parsers.SelectExpandBinder.GenerateExpandItem(ExpandTermToken tokenIn)\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\r\n at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)\r\n at Microsoft.OData.Core.UriParser.Parsers.SelectExpandBinder.Bind(ExpandToken tokenIn)\r\n at Microsoft.OData.Core.UriParser.Parsers.SelectExpandSemanticBinder.Bind(IEdmStructuredType elementType, IEdmNavigationSource navigationSource, ExpandToken expandToken, SelectToken selectToken, ODataUriParserConfiguration configuration)\r\n at Microsoft.OData.Core.UriParser.ODataQueryOptionParser.ParseSelectAndExpand()\r\n at Microsoft.Crm.Extensibility.OData.MetadataQueryOptionsConverter.BindSelectExpand(EntityQueryExpression qe, SelectExpandQueryOption selectExpandQueryOption)\r\n at Microsoft.Crm.Extensibility.OData.QueryOptionsConverterBase`4.GetQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context)\r\n at Microsoft.Crm.Extensibility.OData.MetadataQueryOptionsConverter.GetEntityQueryExpression(ODataQueryOptions queryOptions, String edmEntityName, CrmODataExecutionContext context, String key)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataMetadataServiceDataProvider.RetrieveEdmEntityCollection(CrmODataExecutionContext context, String entitySetName, String castEntityName, ODataQueryOptions queryOptions)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySetInternal(String entitySetName, String castEntityName, CrmODataExecutionContext context, CrmEdmEntityObjectCollection crmEdmEntityObjectCollection, ODataQueryOptions queryOptions)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.GetEntitySet(String entitySetName)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()" } } }

Can you please help me to get "MinValue" & "MaxValue" in the above query?

Regards

John 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    johnguhan Profile Picture
    164 on at
    RE: Retrieve entity metadata of MaxValue and MinValue for decimal field in CRM 2016

    Thank you. Really appricate your help.

  • Verified answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    RE: Retrieve entity metadata of MaxValue and MinValue for decimal field in CRM 2016
    Hi,
    Please find the Web API query. Please replace account name with your custom entity name. This query will work for v9.1 online version. 
    /api/data/v8.1/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.DecimalAttributeMetadata?$select=LogicalName,MaxValue,MinValue
     
    You will need to make some changes in the Query to support for 2016 CRM
    1. Get entity metadata ID .Please replace account name with your custom entity name.
      /api/data/v8.1/EntityDefinitions?$filter=LogicalName eq 'account'&$select=LogicalName,MetadataId
    2. Make a request with Metadata ID.  
      /api/data/v8.1/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes/Microsoft.Dynamics.CRM.DecimalAttributeMetadata?$select=LogicalName,MaxValue,MinValue
     
    Explanation: MinValue and MaxValue are specific to Decimal field, so it is important to cast the Attributes collection-valued navigation property to the type you want.
    MicrosoftTeams_2D00_image-_2800_18_2900_.png
  • johnguhan Profile Picture
    164 on at
    RE: Retrieve entity metadata of MaxValue and MinValue for decimal field in CRM 2016

    David,

    Thanks for the link. I tried different queries using your link but still I’m not able to get the MinValue & MaxValue from the result.

    http:// / /api/data/v8.1/EntityDefinitions?$filter=EntitySetName%20eq%20%27cel_test%27&$select=MetadataId%20&$expand=Attributes($select=MaxValue;$filter=AttributeType%20eq%20Microsoft.Dynamics.CRM.AttributeTypeCode%27Decimal%27)

    Really appreciate if you could send the sample query.

    Regards

    John

  • David Jennaway Profile Picture
    14,065 on at
    RE: Retrieve entity metadata of MaxValue and MinValue for decimal field in CRM 2016

    You will need to cast the result to a DecimalAttributeMetadata type - see https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-metadata-web-api for some example

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans