Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Custom API - Editable

Posted on by 35
Hello all,
 
I am creating a custom api page and have the following requirments 
 
1) on a POSTto create the new record i need the ability to include information for all fields example 
{
firstname: "John",
lastname: "Doe",
Age: "5",
}
 
After the record is created i want to be able to issue a PATCH command to update the age
{
age="6"
}
 
this works correctly 
QUESTION: How do i limit the patch so that only age can be updated but not first or last name, so the below should error
{
firstname: "Bob",
lastname: "Doe",
Age: "5",
}
1)Setting the editable property on the field seems to prevent entering data on the Original post
 
Categories:
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 11,483 Most Valuable Professional on at
    Custom API - Editable
    Hi
    According to our colleague, you can be guided by some examples like the following one in which based on conditionals in the validate event you can verify what you mention, or generate errors.
    Best
    GR
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 72,254 Super User 2024 Season 2 on at
    Custom API - Editable
    Hi, I think writing some control code on trigger OnValidate() will do the trick.
     
    For example, 
    if Age <> '' then
    error('You can  not modify first or last name')
     
    Hope this can give you some hints.
    Thanks.
    ZHU

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 Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

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,946 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,426 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans