Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

can I sort an API with variables defined in the page or can I do this only with fields from the table?

Posted on by 64

Hellog guys,

My question is if I'm allow to sort an API with variables defined in the page or can I do this only with fields from the table?

For example I'm trying to sort Items custom API using a variable ModelNumber and I'm getting the following error:

{
"error": {
    "code": "Unknown",
    "message": "The supplied field number '-1' cannot be found in the 'Item' table.  CorrelationId:  c1f2fa30-3c53-449f-99c2-3350065e428c."
}

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    RE: can I sort an API with variables defined in the page or can I do this only with fields from the table?

    Hi, just adding some info.

    In fact, variables are not only in the API, but also cannot be sorted on the page.

    For example,

    pastedimage1671495028237v1.png

    pastedimage1671495042889v2.png

    Real field:

    pastedimage1671495059964v3.png

    So if you want to sort by your variable, you need to create a new field in the table and add it as a new second key would be better.

    https://yzhums.com/10699/

    Hope this helps as well.
    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: can I sort an API with variables defined in the page or can I do this only with fields from the table?

    Please refer the below links

    learn.microsoft.com/.../ui-enter-criteria-filters

    learn.microsoft.com/.../devenv-orderby-property

    learn.microsoft.com/.../devenv-connect-apps-filtering

  • Daniel Mitrea Profile Picture
    Daniel Mitrea 64 on at
    RE: can I sort an API with variables defined in the page or can I do this only with fields from the table?

    is there other way to sort without adding the variables as fields on the table ?

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: can I sort an API with variables defined in the page or can I do this only with fields from the table?

    Variable is not accessibly through API

  • Daniel Mitrea Profile Picture
    Daniel Mitrea 64 on at
    RE: can I sort an API with variables defined in the page or can I do this only with fields from the table?

    I added the variables on custom API Items page and then trying to test using Postman call.

    api.businesscentral.dynamics.com................................................................../Items

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: can I sort an API with variables defined in the page or can I do this only with fields from the table?

    Hi,

    Variable defined on Page not available with API on normal page.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans