Skip to main content

Notifications

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 ?

  • Verified answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Disable the Line level field

    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.

  • NoobGamer Profile Picture
    NoobGamer 2 on at
    RE: Disable the Line level field

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

  • NoobGamer Profile Picture
    NoobGamer 2 on at
    RE: Disable the Line level field

    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

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Disable the Line level field

    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.

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,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans