Announcements
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
}
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.
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
Hi Zhi Jiang,
This field cannot be set as blank. The field is mandatory in PurchReqLine.
Why do you need this field to be set to blank?
André Arnaud de Cal...
293,311
Super User 2025 Season 1
Martin Dráb
232,183
Most Valuable Professional
nmaenpaa
101,158
Moderator