How to find the country region code in D365 for X++
LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId
How to find the country region code in D365 for X++
LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId
In SQL:-
SELECT
HW.PersonnelNumber,
PU.USER_
FROM
HcmWorker AS HW
JOIN
DirPersonUser AS PU ON HW.Person = PU.PersonParty
WHERE
PU.USER_ = 'Akhil';
Creating a Global Action Button in D365 Accounts Payable Parameters.
[FormControlEventHandler(formControlStr(VendParameters, VendParameters_YNV_VendorMasterDeletionOption), FormControlEventType::Modified)]
public static void VendParameters_YNV_VendorMasterDeletionOption_OnModified(FormControl sender, FormControlEventArgs e)
{
VendParameters vendParameters;
FormCheckBoxControl formCheckBoxControl = sender as FormCheckBoxControl;
ttsBegin;
while select
forUpdate crossCompany
YNV_VendorMasterDeletionOption,DataAreaId
from
vendParameters where vendParameters.DataAreaId != curExt()
{
changeCompany(vendParameters.dataAreaId)
{
vendParameters.YNV_VendorMasterDeletionOption = formCheckBoxControl.checked();
vendParameters.update();
}
}
ttsCommit;
}
Based on the condition, grid fields should not be editable for a particular form datasource.
[ExtensionOf(formDataSourceStr(LedgerJournalTransVendPaym, LedgerJournalTrans))]
public final class YNV_LedgerJournalTransVendPaym_LedgerJournalTransDatasource_Extension
{
public int active()
{
LedgerJournalTrans LedgerJournalTrans = this.cursor();
VendParameters vendParameters = vendParameters::find();
FormDataSource LedgerJournalTrans_ds = this;
FormDataSource LedgerJournalTrans_W_ds = this.formRun().dataSource(formDataSourceStr(LedgerJournalTransVendPaym,LedgerJournalTrans_W ));
LedgerJournalTrans_W LedgerJournalTrans_W = LedgerJournalTrans_W_ds.cursor();
int ret = next active();
if(vendParameters.YNV_EditVendPaymProposal == NoYes::Yes)
{
if(LedgerJournalTrans.YNV_IsPaymProposal == NoYes::Yes)
{
allowEditFieldsOnFormDS_W(LedgerJournalTrans_ds, false);
allowEditFieldsOnFormDS_W(LedgerJournalTrans_W_ds, false);
LedgerJournalTrans_ds.object(fieldNum(LedgerJournalTrans, Txt)).allowEdit(true);
LedgerJournalTrans_ds.object(fieldNum(LedgerJournalTrans, TransDate)).allowEdit(true);
LedgerJournalTrans_W_ds.object(fieldNum(LedgerJournalTrans_W, ServiceLevel)).allowEdit(true);
LedgerJournalTrans_W_ds.object(fieldNum(LedgerJournalTrans_W, ChargeBearer)).allowEdit(true);
}
else
{
allowEditFieldsOnFormDS_W(LedgerJournalTrans_ds, true);
allowEditFieldsOnFormDS_W(LedgerJournalTrans_W_ds, true);
}
}
else
{
allowEditFieldsOnFormDS_W(LedgerJournalTrans_ds, true);
allowEditFieldsOnFormDS_W(LedgerJournalTrans_W_ds, true);
}
return ret;
}
My Requirement is to Ensure correct defaulting, restriction, and error handling for Legal Entity selection in the Purchase Requisition.
When a user selects a legal entity in the Purchase Requisition header, it should default to each line item.
If no legal entity is selected at the header level, prevent the addition of line items and display an error message: “Please select the legal entity from PR header financial dimension.”
The Legal Entity field in the header can only be modified if there are no line items. If line items exist and the user attempts to change the Legal Entity, display an error message: “Cannot change the legal entity after lines have been added.”
validate write method:-
public boolean validateWrite()
{
boolean ret;
str legalEntity,legalEntityLine;
ret = next validateWrite();
PurchReqLine purchReqLine;
select firstonly purchReqLine order by LineNum desc where purchReqLine.PurchReqTable == this.RecId ;
if (this.DefaultDimension != 0 && purchReqLine.LineNum > 0)
{
legalEntity = this.getDimValue(this.DefaultDimension);
legalEntityLine = this.getDimValue(purchReqLine.DefaultDimension);
if(legalEntity != legalEntityLine)
{
ret = checkFailed(strFmt("The Legal entity at the header level cannot be changed"));
}
}
return ret;
}
To get the dimension values:-
public DimensionValue getDimValue(PurchReqDefaultDimensionValueSet purchReqDefaultDimensionValueSet)
{
DimensionAttributeValueSet DimensionAttributeValueSet;
DimensionAttributeValueSetItem DimensionAttributeValueSetItem;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttribute DimensionAttribute;
;
select RecId from DimensionAttributeValueSet
where DimensionAttributeValueSet.RecId == purchReqDefaultDimensionValueSet
join DisplayValue from DimensionAttributeValueSetItem
where DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecId
join RecId from DimensionAttributeValue
where DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValue
join RecId from DimensionAttribute
where DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
&& DimensionAttribute.Name == "LegalEntity";
return DimensionAttributeValueSetItem.DisplayValue;
}
Total Grid Non-Editable:-
FormGridControl grid = element.design().controlName(formControlStr(YNV_InternalPuchaseRequisitionForm, YNV_InternalPurchaseRequisitionGrid));
grid.allowEdit(NoYes::No);
============================================================
Only one record is editable at the grid level.
In datasource's init() method after super() simply call:
allowEditFieldsOnFormDS_W(CustInvoiceJour_ds, false);
CustInvoiceJour_ds.object(fieldNum(CustInvoiceJour, PrintedOrginal)).allowEdit(true);
How to find the country region code in D365 for X++ LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext()...