Showing posts with label onQueryExecuting.. Show all posts
Showing posts with label onQueryExecuting.. Show all posts

Event handler for QueryExecuting to filter data

Event handler for QueryExecuting to filter data


You can use the below code sample to filter data in query execution event

1. Copy Form ->Data source  >Event > onQueryExecuting.
2. Paste this code in the New class.



  [FormDataSourceEventHandler(formDataSourceStr(PayrollEmployerTaxRegion, PayrollEmployerTaxRegion), FormDataSourceEventType::QueryExecuting)]
    public static void PayrollEmployerTaxRegion_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)

    {

        sender.query().dataSourceName(sender.name()).addRange(fieldnum(PayrollEmployerTaxRegion,     CountryRegionId)).value(queryValue(LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId));

    }

Support Faryal's Cusine


Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...