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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Disable the Line level field

(0) ShareShare
ReportReport
Posted on by 2

Hi , 

    I have to disable the unit price field from editing , untill  Each line items gets saved in the table level . 

Since InventTransId for each line will be generated only when the line item is saved . (If there is any error system wont generate InventTransId ). As I am inserting some data into the custom table whenever the unitprice is modified .

So I need to disable the UnitPrice field of the particular line  untill the system generates the InventTransId .Is it possible to do that . If so can someone tell me how to achieve that using chain of command ?

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,833 Moderator on at

    Hi NoobGamer,

    As you said already InventTransId field will be generated only after the particular line item is saved.

    In that scenario you can add the code in the write method of form datasource level.

    Add COC for write method - Get the current cursor - Based on the cursor check whether the InventTrans Id field is not empty - enable the field - If its a empty you can disable the Unit price field.

    Also disabling the particular field will disable that control for all the lines. So you need to add the same code in "SelectionChanged" method of form datasource also.

    Thanks,

    Girish S.

  • NoobGamer Profile Picture
    2 on at

    Hi Girish ,


             

    [ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]
    final class SalesLine_DS_Extension
    {
        public int active()
        {
            int ret = next active();
    
            SalesLine salesLineLocal = this.cursor();
    
            if(salesLineLocal.RecId == 0 )
            {
               this.object(fieldNum(SalesLine, SalesPrice)).allowEdit(false);
            }
            else
            {
                this.object(fieldNum(SalesLine, SalesPrice)).allowEdit(true);
            }
                return ret;
      
        }
    
    }

    This code works but I need to write some additional conditions ,whether can I call the formdatasource write method inside the formdatasource active(COC) method

  • NoobGamer Profile Picture
    2 on at

    Because I need the return value of write method inside the active method

  • Verified answer
    GirishS Profile Picture
    27,833 Moderator on at

    What additional code you want to write?

    If it works on the active method - You can write the logic on the active method itself.

    No need to call the write method - It will be called automatically when you click the save button.

    Thanks,

    Girish S.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 509 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans