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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Custom API - Sales Order - Import but Not Validate

(5) ShareShare
ReportReport
Posted on by 92
Dear experts,
 
I created a custom API by copying the base code and add a few lines to include my custom fields.
I wish to import <Requested Delivery Date> from my custom API and not validate it so that the value of <Requested Delivery Date> doesn't trigger the downstream function where it'd override the Planned Delivery Date in the Sales Order Lines.
I tried to remove the on validate function but that will result in null value.
 
Postman Result after remove on validate:
 
                field(requestedDeliveryDate; Rec."Requested Delivery Date")
                {
                    Caption = 'Requested Delivery Date';
                    trigger OnValidate()
                    begin
                        RegisterFieldSet(Rec.FieldNo("Requested Delivery Date"));
                    end;
                }
I have the same question (0)
  • Suggested answer
    Holly Huffman Profile Picture
    6,530 Super User 2025 Season 2 on at
    Good morning, afternoon, or evening depending on your location!
     
    It looks like removing the OnValidate trigger is causing the Requested Delivery Date field to return a null value in your custom API.
    The issue likely arises because the field is not being explicitly set when validation is removed.
     
    Possible Solutions:
    1. Manually Assign the Field Value:
      • Instead of relying on validation, explicitly set the field value in the API logic.
      • Example:
        field(requestedDeliveryDate; Rec."Requested Delivery Date")
        {
            Caption = 'Requested Delivery Date';
            trigger OnInsert()
            begin
                Rec."Requested Delivery Date" := requestedDeliveryDate;
            end;
        }
      • This ensures the field is populated without triggering validation.
    2. Use a Temporary Field:
      • Create a temporary field to store the Requested Delivery Date before applying it to the actual field.
      • This prevents downstream functions from overriding the Planned Delivery Date.
    3. Modify API Behavior:
      • If the API automatically triggers validation, consider overriding the default behavior by using a custom extension.
    4. Check API Response Handling:
      • Ensure that the API correctly maps the field in the response.
      • If the field is missing, verify that it is included in the API definition.
     
    Hope this helps some!
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,441 Super User 2025 Season 2 on at
  • Suggested answer
    YUN ZHU Profile Picture
    95,681 Super User 2025 Season 2 on at
    Hi, The logic of this part is quite special. It is not directly inserted into the Sales Header, but through the intermediate table. If you delete this part of the code, it means that this value is not inserted into the intermediate table, so it is empty.
     
    I suggest you try to restore the value after OnInsert. This should solve the problem.
     
     
    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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,606

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans