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 :
Microsoft Dynamics AX (Archived)

How to disable editable for all of the fields except two in a form for a selected record only

(0) ShareShare
ReportReport
Posted on by 272

I found this, however I think this solution is disabling all the fields no matter what record you're in, it completely disables the fields in the form (correct me if I'm wrong).

Also I don't know how to obtain the datasource "salesAgreementHeader_ds" (I'm working on sales agreement) using main(Args _args)

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahmoud Hakim Profile Picture
    17,887 on at

    I suggest to implement this by security, you can go to security role and click override permission and set your permission for this table

  • Miguel Zuniga Profile Picture
    272 on at

    I am working on SalesAgreement form. I want to make ALL the data sources not editable. Except two.

  • André Arnaud de Calavon Profile Picture
    304,500 Super User 2026 Season 1 on at

    Hi Miguel,

    Your initial post suggests that you might have a requirement for disabling fields based on what agreement is selected. Possibly status related. Is this assumption correct? Please elaborate.

  • Miguel Zuniga Profile Picture
    272 on at

    An update to my question..

    I've used this code, I placed it on the init of the form method.

    But it doesn't work. I can still edit the fields in the lines.

        SalesAgreementHeader                salesAgreementHeaderLoc;
        SalesAgreementHeader                salesAgreementHeaderRecord;
        AgreementLine                       agreementLineLoc;
        AgreementLineQuantityCommitment     agreementLineQuantityCommitmentLoc;
        RecId                               salesAgreementRecId;
        DictTable                           agreementLineDictTable, agreementLineQuantityCommitmentDictTable;
        int                                 fieldCnt, fieldNumber;
    
        salesAgreementHeaderRecord = element.args().record();
        agreementLineDictTable = new DictTable(agreementLineLoc.TableId);
        agreementLineQuantityCommitmentDictTable = new DictTable(agreementLineQuantityCommitmentLoc.TableId);
    
        if(salesAgreementHeaderRecord)
        {
            select HSIsChangeRequest from salesAgreementHeaderLoc
                where salesAgreementHeaderLoc.RecId == salesAgreementHeaderRecord.RecId;
    
            if(salesAgreementHeaderLoc.HSIsChangeRequest == NoYes::Yes)
            {
               //datasources in the form
                SalesAgreementHeader_ds.allowEdit(false);
                AgreementHeaderDefault_ds.allowEdit(false);
                SalesAgreementHeaderDefault_ds.allowEdit(false);
                InventDim_ds.allowEdit(false);
                TMSSalesAgreementHeader_ds.allowEdit(false);
                SalesAgreementHeaderExt_RU_ds.allowEdit(false);
                HSSalesContractSections_ds.allowEdit(false);
                //ALine_ds.allowEdit(false); //commented out
                ALine_ds.allowCreate(false);
                AgreementLineDefault_ds.allowEdit(false);
                AgreementLineExt_RU_ds.allowEdit(false);
                //ALine_AgreementLineQuantityCommitment_ds.allowEdit(false); //commented out
                ALine_AgreementLineVolumeCommitment_ds.allowEdit(false);
    
                //for fields in agreement line quantity commitment table, because I only need two to be enabled
                for(fieldCnt = 1 ; fieldCnt <= agreementLineQuantityCommitmentDictTable.fieldCnt(); fieldCnt++)
                {
                    fieldNumber = agreementLineQuantityCommitmentDictTable.fieldCnt2Id(fieldCnt);
                    if(ALine_AgreementLineQuantityCommitment_ds.object(fieldNumber)
                       && fieldNumber != fieldNum(AgreementLineQuantityCommitment, CommitedQuantity)
                       && fieldNumber != fieldNum(AgreementLineQuantityCommitment, PricePerUnit))
                    {
                        ALine_AgreementLineQuantityCommitment_ds.object(fieldNumber).allowEdit(false);
                    }
                }
                
                //for fields in agreement line, because I only need two to be enabled
                for(fieldCnt = 1 ; fieldCnt <= agreementLineDictTable.fieldCnt() ; fieldCnt++)
                {
                    fieldNumber = agreementLineDictTable.fieldCnt2Id(fieldCnt);
                    if(ALine_ds.object(fieldNumber)
                       && fieldNumber != fieldNum(AgreementLine, DeliveryPeriod)
                       && fieldNumber != fieldNum(AgreementLine, DeliveryYear))
                    {
                        ALine_ds.object(fieldNumber).allowEdit(false);
                    }
                }
            }
        }
    


  • Verified answer
    André Arnaud de Calavon Profile Picture
    304,500 Super User 2026 Season 1 on at

    Hi Miguel,

    Please try to use this coding on the Active() method of the datasource. I haven't reviewed the full coding, but the init() method is only called when opening the form and then has no records loaded yet.

  • Miguel Zuniga Profile Picture
    272 on at

    Thanks André! You were right, I just have to place it in the right method.

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans