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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Write method not called after click on save button

(0) ShareShare
ReportReport
Posted on by 163

First Q : I want to add validation before saving records in database but write method doesn't called and records save without getting the error message .

How to make write method called and records doesn't save if getting the errror ?

1715.Screenshot-_2800_34_2900_.png

second Q : 

I want to make priority field in table to be an auto increment and show automatic when click on add button so I wrote code on init value () datasource method and made a method on table but it gets the max priority on table not on table in this loan item . 

how to fix this ? 

3716.Screenshot-_2800_31_2900_.png0336.Screenshot-_2800_30_2900_.png2337.Screenshot-_2800_33_2900_.png

I have the same question (0)
  • Martin Dráb Profile Picture
    236,822 Most Valuable Professional on at
    RE: Write method not called after click on save button

    write() method isn't the right place for validations. Use validateWrite() instead.

    Please create a separate thread for the other question. Thw topic of this one is "Write method not called after click on save button".

    By the way, I moved your question to the right forum and change the category to "Development / Customization / SDK".

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: Write method not called after click on save button

    Hi Menna Allah Ahmed,

    For validating records, you can make use of validateWrite method on table or form DataSource level.

    For increment of number, you need to get max number and then increment by 1.

    Thanks,

    Girish S.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: Write method not called after click on save button

    For increment of number , I increment by 1 in init value() but it always returns 5 even if no records in this loan item .

    For validating records , I write code on validate write but it return the error on record level not on all record .

    I want to sum all ratio in grid and throw error if it less than 100 but validate write doesn't make me to add new record to sum all

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Write method not called after click on save button

    Seems Loan item is in header table. Your priority field is in Allocation grid, which is a separate table, I guess.

    You have added the select statement for getting maximum priority number against the loan item id.

    In the header table you have 4 records - So its adding by 1 you are getting 5 as priority number.

    Remove the LoanItemId in select statement and check.

    Thanks,

    Girish S.

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Write method not called after click on save button

    For validation the system doesn't know which is the last record and validateWrite method will be called for each line. So, it will check allocation ratio for each line - will throw error at each line if its less then 100 and it will not allow you to create new line.

    Thanks,

    Girish S.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: Write method not called after click on save button

    For increment number , it doesn't work it also returns 5 the max number of priority in allocation table .

    there are separate table but it has a relation between them by loan item .

    For validation , which method I can write code to validate after enter all records I want ?

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Write method not called after click on save button

    I was wrong, your select statement must have LoanItem to get the max priority number. Debug the code and check whether load item id is passed as argument. Also open the table browser and see how may records are there against loan Item in allocation grid table.

    As I already said system doesn't know which is the last record - Try adding the code on the leave method of the grid. Better option will be adding validate button on the allocation grid action pane and user have to click the validate button and check.

    Thanks,

    Girish S.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: Write method not called after click on save button

    I will try it , but I want to know the reason of why write method doesn't called ?

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: Write method not called after click on save button

    Write method is not used for validating records entered. It doesn't have any return type.  Write method will call the validateWrite method to validate the records and then the table insertion will happen.

    Refer to the below blog for sequence of method calls.

    http://axhelper.com/?p=3253

    Thanks,

    Girish S.

  • Menna Allah Ahmed Profile Picture
    163 on at
    RE: Write method not called after click on save button

    thank you for your effort .

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 765 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 743

#3
Sumit Singh Profile Picture

Sumit Singh 551

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans