Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

How I Add my basic field in my form.

(0) ShareShare
ReportReport
Posted on by 253
Dear All,
 
I have a question that I customize my from to add a basic field  and after press /OK/ it should be flow to save data in my table.
//
 
1. I Extend a form /EcoResProductCreate/ but for this form it don't have a data Source
//
 
 
After that I would like to edit a OK button to do everything to be the same but add data on customize field/HSCODE/ to table /EcoResProduct/ 
Same table of field /Product Number/
//
 
But I don't know how to do? I try to create a class extension to save data in the same table but I don't know how to do?
 
//
 
Can someone guide me how to do?
 
Thanakorn
  • Verified answer
    Chomchanok Profile Picture
    Chomchanok 253 on at
    How I Add my basic field in my form.
     
    Let's I update my issue: For now I think my issue is resolved.
     
    Thank you for your guideline.
  • Chomchanok Profile Picture
    Chomchanok 253 on at
    How I Add my basic field in my form.
     
    Thank you for your guideline. After I got your information then I try to do step by step
    1. I Extend My class.
    2. I right click and Copy Event Handler Method
    3.I press in my (Extend) Class then I try to simulate a logic that should be here but I don't know how to refer my field in that form?


     



  • Waed Ayyad Profile Picture
    Waed Ayyad 6,500 Super User 2024 Season 2 on at
    How I Add my basic field in my form.
    Hi,
     
    Did you try the hints I give it to you? Do you want additional help?
     
     
     
    Thanks,
    Waed Ayyad
     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,500 Super User 2024 Season 2 on at
    How I Add my basic field in my form.
    Hi,
     
    You can start from here:
    internal final class EcoResProductCreateFormHSTH_EventHandler
    {    
        
     [FormControlEventHandler(formControlStr(EcoResProductCreate, OKButton), FormControlEventType::Clicked)]   
     public static void OKButton_OnClicked(FormControl sender, FormControlEventArgs e)   
     { 
          FormRun formRun = sender.formRun();         
          //Add your logic 
     }  
    }
    
     
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,500 Super User 2024 Season 2 on at
    How I Add my basic field in my form.
     
    From here right click on the Event OnClicked then choose Copy Event handler Method:
     
     
  • Chomchanok Profile Picture
    Chomchanok 253 on at
    How I Add my basic field in my form.
     
    thank you for your guideline.
    1. first of all did you added the field to table? (Yes)
     
    I see from the code that you write you created a display method
    (This is a mock up class that I don't know where I can write the code, On the concept I know that I need to override the even handler for "OK Button" but I try to click left,right but I didn't see a menu to do override method).
     
    and this is a code that I prepare for but I don't know where I put my code 
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    [ExtensionOf(formStr(EcoResProductCreate))]
    final class EcoResProductCreate_HSTH_Extension
    {
        public void clicked()
        {
            // Override the clicked method for the OK button to save data
            super();
            // Access your custom field value
            str hSCodeValue = this.design().HSCODE.value();
            // Create a new record buffer for EcoResProduct table
            EcoResProduct ecoResProduct;
            // Insert your custom logic to populate the record buffer with data
            //ecoResProduct.ProductNumber = // Populate with appropriate value;
            ecoResProduct.HSCODE = hSCodeValue; // Populate with your custom field value
            // Save the record
            ttsBegin;
            ecoResProduct.insert();
            ttsCommit;
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
  • Suggested answer
    Waed Ayyad Profile Picture
    Waed Ayyad 6,500 Super User 2024 Season 2 on at
    How I Add my basic field in my form.
     
    You can add logic to insert the data on the new Field but first of all did you added the field to table? Also, I see from the code that you write you created a display method; it is not correct you should debug the code of the click method and see how the product number is created and then you can think how to add your logic to fill your field.
     
    You can use on click event handler of your method and add your code there. the following blog show to add event handler for your button.
     
    Try it and share your code for more details.
     
    Thanks,
     Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,379 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans