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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Set PurchReqLine.BuyingLegalEntity default value is blank

(0) ShareShare
ReportReport
Posted on by 5

I am a newcomer to D365, I encountered a problem in the development, requesting a new purchase request line to purchase a legal person with a default value of empty, tried a variety of methods, his default value can not override the following is my code.

[ExtensionOf(formDataSourceStr(PurchReqTable, PurchReqLine))]
final class IWS_PurchReqTable_FDS_Extension
{
    
    public void initValue()
    {
        next initValue();
        ttsbegin;
        PurchReqLine purchReqLine = this.cursor();
        purchReqLine.BuyingLegalEntity = 0;
        purchReqLine.modifiedField(fieldNum(PurchReqLine,BuyingLegalEntity));        
        //this.rereadReferenceDataSources(); //Refresh value

        //this.research(1);
        

        FormReferenceGroupControl BuyingLegalEntity = this.formRun().design().controlName(formControlStr(PurchReqTable, PurchReqLine_BuyingLegalEntity));
        FormStringControl BuyingLegalEntity_DataArea = this.formRun().design().controlName(formControlStr(PurchReqTable, PurchReqLine_BuyingLegalEntity_DataArea));
        BuyingLegalEntity.value(0);


        BuyingLegalEntity.resolveChanges();
        BuyingLegalEntity.referenceDataSource().research(1);
        BuyingLegalEntity.modified();
        //BuyingLegalEntity_DataArea.text('');
        //BuyingLegalEntity_DataArea.modified();

        purchReqLine.BuyingLegalEntity = 0;
        purchReqLine.modifiedField(fieldNum(PurchReqLine,BuyingLegalEntity));
        //purchReqLine.update();
        //purchReqLine.insert();
        this.rereadReferenceDataSources();
        //this.refresh();
        //this.reread();
        this.resetLine();
        ttscommit;
    }
    //End

}
1644565705_2800_1_2900_.png

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Zhi Jiang,

    This field cannot be set as blank. The field is mandatory in PurchReqLine.

    pastedimage1644700604932v1.png

    Why do you need this field to be set to blank? 

  • ZHI JIANG Profile Picture
    5 on at

    The customer means that the default value is empty at the time of creation, and then set to required to prompt the customer to select the appropriate BuyingLegalEntity

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    That won't be possible with the current design, since a line cannot be created without this field being populated. What you could try doing is to create a custom field like BuyingLegalEntity and hide the original field on the form. When this new field is populated by the user, you can update the BuyingLegalEntity field with the same value.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans