Skip to main content

Notifications

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

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Set PurchReqLine.BuyingLegalEntity default value is blank

    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.

  • ZHI JIANG Profile Picture
    5 on at
    RE: Set PurchReqLine.BuyingLegalEntity default value is blank

    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

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Set PurchReqLine.BuyingLegalEntity default value is blank

    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? 

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,311 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,183 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans