Skip to main content

Notifications

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

save record when modifying a field

(2) ShareShare
ReportReport
Posted on by 1,325
Hi,

I added a tickBox field to salesLine table, and added this field to two forms in the grid: 'salesTable' form and 'ProjSalesItemReq' form.

Now when this tickBox is modified, i want to save the salesLine record.

is this the correct way to do it
 
[ExtensionOf(formDataFieldStr(ProjSalesItemReq, SalesLine, TickBox))]
final class ProjSalesItemReqFormSaleslineDS_TickBox_Extension
{
    public void modified()
    {
        FormDataObject formDataObject = any2Object(this) as FormDataObject;
        FormDataSource formDataSource = formDataObject.datasource();

        next modified();

        formDataSource.write();
    }
}
[ExtensionOf(formDataFieldStr(SalesTable, SalesLine, TickBox))]
final class SalesTableFormSaleslineDS_TickBox_Extension
{
    public void modified()
    {
        FormDataObject formDataObject = any2Object(this) as FormDataObject;
        FormDataSource formDataSource = formDataObject.datasource();

        next modified();

        formDataSource.write();
    }
}
 
 
The reason I need to do this, is because as you know, when we move between lines in the grid, the record gets saved automatically. So what happens is, the user ticks the first line and moves to the 2nd line and tick it, after that that user clicks a button that looks for lines that have this tickBox as true and they forget to click save, so when they click the button, the code doesn't see that the last line has this tickBox as true. And that's why i want to save the record automatically when modifying the tick box field
Categories:
  • .. Profile Picture
    .. 1,325 on at
    save record when modifying a field
    Hi @André Arnaud de Calavon

    can you help please?
  • .. Profile Picture
    .. 1,325 on at
    save record when modifying a field
    Hi Andre,

    The menu item has 'save record' property set to yes

    this menu item opens dialog form and yes the code is on "clicked" method after the super

     
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,162 Super User 2025 Season 1 on at
    save record when modifying a field
    Hi,

    You should not have to manually save the record with X++ coding.
    When a property Save record is set to Yes on the button or menu item button, it should first save the record and then perform the action. In case you have written X++ logic on the clicked() method of a button control, did you write your code after the super() statement?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans