Mam, There is Field in Customer Card 'Post Code' i want to validate it . User can only Insert Numeric value and length only 6 digit . how can i validate
Try this in the postcode field trigger() trigger OnValidate() var IsNumeric: Boolean; begin // Check if the Post Code is exactly 6 digits long if StrLen("Post Code") 6 then Error('The Post Code must be exactly 6 digits long.'); // Check if the Post Code is numeric IsNumeric := true; foreach var Char in "Post Code" do if not Char.IsDigit() then IsNumeric := false; if not IsNumeric then Error('The Post Code must contain only numeric values.'); end; }
Dr. S. Gomathi I want to thank you for wanting to help us with your wonderful videos, they are truly excellent. Would you like to help me with a challenge I have with a client? I have to hit an endpoint of an app outside of BC by sending in the request body the values contained in the "Sell-to Customer No." and "No." fields of that same record and a token in the headers when the value in the "Status" field of the Sales Header table (36) changes to "Launched". Do you want to help me Dr.? 🙏🏻 Thanks in advance!
Thank you for your kind words and appreciation! I'm glad you find the videos helpful. I'd be happy to assist you with the challenge you're facing. To achieve your goal of hitting an endpoint outside of Business Central when the "Status" field of the Sales Header table changes to "Launched," you can leverage the Business Central eventing mechanism. 1. Create a codeunit: Start by creating a codeunit in Business Central, which will handle the event triggering and API call. You can define a function within the codeunit that listens to the "Status" field changes in the Sales Header table. 2. Event Subscription: In Business Central, navigate to the Events page and subscribe to the OnAfterModify event of the Sales Header table. Assign your codeunit and function to handle this event. 3. Implement the API Call: Inside the function, write the code to check if the "Status" field has changed to "Launched." If it has, retrieve the necessary values from the "Sell-to Customer No." and "No." fields of the Sales Header table. Then, use an HTTP library or function within Business Central to make the API call to the desired endpoint outside of Business Central. Ensure that you include the token in the headers and pass the required values in the request body. Remember to handle any error scenarios and ensure proper error logging within your codeunit. I hope this helps you get started with your challenge! If you need further assistance or have more specific questions, feel free to ask. Good luck with your project!
@@gomstechtalks Thank you very much for wanting to help me. I already managed to implement the code in AL with your advice and I have two specific questions about an error I have with the token, but I would like to share the code with you. Can I send it to you by any means? Thank you very much for wanting to help me.
@@gomstechtalks Dr. Gomathi, I already figured out how to solve the token issue so sending the code may not be necessary. I only have one question left: How do I subscribe to the event when a value changes in the "Status" field and not to the entire record, because now I am subscribed to the event when a value changes in the entire record and then I evaluate the content of that field that is not the most appropriate according to your recommendations.
Hi Dr. Hope you are fine. Please need your suggestion for correct place. i wrote code in page variable. This is correct place or not field("Applicant Age"; Rec."Applicant Age") { ApplicationArea = All; Caption = 'Applicant age'; Visible = false; trigger OnValidate() begin if Rec."Applicant Age"
I have a form in my page I want to show validation error message if any single form field is empty when I click OK button..so what can be done.. show mandatory is working but i have to show on clicking OK button on page.
@@gomstechtalks while creating page we get two buttons OK and Cancel, i have applied validation on ontrigger event but when I click on OK button the data are getting saved even it's blank..so while clicking the OK button I want to show validation error message. (Don't have code for this only created page and table fields).so can you help in this?
Hi Dr. Gomathi, Where to get the source code for this , Employeee source code. I am unable to locate it in your blog. Could you forward the link to me. Thank you very much.
Your way of explaining was very simple to understand for a fresher !! Subscribing your channel :)
Glad to hear. Thank you so much for taking the time to appreciate it.
Regards,
Dr. Gomathi
thankyu so much ma'am you are very supprting for me thanyou so much heartfully 🙏🙏
Glad and welcome. 😊
Please make some videos on APP publishing using the BC Admin shell.
Sure.
Thank you dear Goms
Glad
Mam, There is Field in Customer Card 'Post Code' i want to validate it . User can only Insert Numeric value and length only 6 digit . how can i validate
Try this in the postcode field trigger()
trigger OnValidate()
var
IsNumeric: Boolean;
begin
// Check if the Post Code is exactly 6 digits long
if StrLen("Post Code") 6 then
Error('The Post Code must be exactly 6 digits long.');
// Check if the Post Code is numeric
IsNumeric := true;
foreach var Char in "Post Code" do
if not Char.IsDigit() then
IsNumeric := false;
if not IsNumeric then
Error('The Post Code must contain only numeric values.');
end;
}
Dr. S. Gomathi I want to thank you for wanting to help us with your wonderful videos, they are truly excellent.
Would you like to help me with a challenge I have with a client? I have to hit an endpoint of an app outside of BC by sending in the request body the values contained in the "Sell-to Customer No." and "No." fields of that same record and a token in the headers when the value in the "Status" field of the Sales Header table (36) changes to "Launched".
Do you want to help me Dr.? 🙏🏻 Thanks in advance!
Thank you for your kind words and appreciation! I'm glad you find the videos helpful. I'd be happy to assist you with the challenge you're facing.
To achieve your goal of hitting an endpoint outside of Business Central when the "Status" field of the Sales Header table changes to "Launched," you can leverage the Business Central eventing mechanism.
1. Create a codeunit: Start by creating a codeunit in Business Central, which will handle the event triggering and API call. You can define a function within the codeunit that listens to the "Status" field changes in the Sales Header table.
2. Event Subscription: In Business Central, navigate to the Events page and subscribe to the OnAfterModify event of the Sales Header table. Assign your codeunit and function to handle this event.
3. Implement the API Call: Inside the function, write the code to check if the "Status" field has changed to "Launched." If it has, retrieve the necessary values from the "Sell-to Customer No." and "No." fields of the Sales Header table. Then, use an HTTP library or function within Business Central to make the API call to the desired endpoint outside of Business Central. Ensure that you include the token in the headers and pass the required values in the request body.
Remember to handle any error scenarios and ensure proper error logging within your codeunit.
I hope this helps you get started with your challenge! If you need further assistance or have more specific questions, feel free to ask. Good luck with your project!
@@gomstechtalks Thank you very much for wanting to help me.
I already managed to implement the code in AL with your advice and I have two specific questions about an error I have with the token, but I would like to share the code with you. Can I send it to you by any means?
Thank you very much for wanting to help me.
Yes please mail to gomstechtalks@gmail.com
@@gomstechtalks Dr. Gomathi, I already figured out how to solve the token issue so sending the code may not be necessary. I only have one question left: How do I subscribe to the event when a value changes in the "Status" field and not to the entire record, because now I am subscribed to the event when a value changes in the entire record and then I evaluate the content of that field that is not the most appropriate according to your recommendations.
Hi Dr. Hope you are fine.
Please need your suggestion for correct place. i wrote code in page variable.
This is correct place or not
field("Applicant Age"; Rec."Applicant Age")
{
ApplicationArea = All;
Caption = 'Applicant age';
Visible = false;
trigger OnValidate()
begin
if Rec."Applicant Age"
field("Original Invoice No."; Rec."Original Invoice No.")
{
ApplicationArea = All;
Caption = 'Original Invoice No.';
NotBlank = true;
ShowMandatory = true;
field("Applicant Age"; Rec."Applicant Age")
{
ApplicationArea = All;
Caption = 'Applicant age';
Visible = false;
trigger OnValidate()
begin
if Rec."Applicant Age"
No, where you have declared/defined "Original Invoice No." and "Reason" ?
@tahermahmood9360
23 hours ago
Hi
This is complete code. please need to check below mention code.
pageextension 50125 Ext_SalesCreditMemo extends "Sales Credit Memo"
{
layout
{
// Add changes to page layout here
addafter("Applies-to ID")
{
field("Test"; Rec."Test")
{
ApplicationArea = All;
Caption = 'Test';
NotBlank = true;
ShowMandatory = true;
}
field("Original Invoice No."; Rec."Original Invoice No.")
{
ApplicationArea = All;
Caption = 'Original Invoice No.';
NotBlank = true;
ShowMandatory = true;
}
field("Reason"; Rec."Reason")
{
ApplicationArea = All;
Caption = 'Reason';
NotBlank = true;
ShowMandatory = true;
}
}
}
actions
{
// Add changes to page actions here
}
var
myint: Integer;
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
begin
if Rec."Test" = '' then
error('Please enter the Test');
if Rec."Original Invoice No." = '' then
error('Please enter the Original invoice no.');
if Rec."Reason" = '' then
error('Please enter the reason');
end;
}
I have a form in my page I want to show validation error message if any single form field is empty when I click OK button..so what can be done.. show mandatory is working but i have to show on clicking OK button on page.
Write it in the button trigger
@@gomstechtalks not clear use action trigger which function but ?
In the ok button? Can you send the code to check. ?
@@gomstechtalks while creating page we get two buttons OK and Cancel, i have applied validation on ontrigger event but when I click on OK button the data are getting saved even it's blank..so while clicking the OK button I want to show validation error message. (Don't have code for this only created page and table fields).so can you help in this?
Please share the table and page code so as to check
Hi Dr. Gomathi, Where to get the source code for this , Employeee source code. I am unable to locate it in your blog. Could you forward the link to me. Thank you very much.
Please check here github.com/Gomathikrishna/D365-Business-Central-AL-Programming
thanks. i send a email. but no responce.😕
Sorry, I didn't see, I am in an official trip. Will check once I am back to the normal routine
@@gomstechtalks oh its okay . No problem ..