{
[FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine, AgreedPrice), FormDataFieldEventType::Modified)]
public static void AgreedPrice_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormRun formRun = sender.datasource().formRun();
FormDataSource SalesLine_DS = formRun.dataSource(formdatasourcestr(SalesTable, SalesLine)) as FormDataSource;
SalesLine sales_line = SalesLine_DS.cursor();
SalesLine Sales_Line_Selected = SalesLine::findRecId(sales_line.RecId);
if(Sales_Line_Selected.AgreedPrice == NoYes::No)
{
SalesLine_DS.object(fieldNum(SalesLine, LinePercent)).enabled(false);
SalesLine_DS.object(fieldNum(SalesLine, LineDisc)).enabled(false);
}
else
{
SalesLine_DS.object(fieldNum(SalesLine, SalesPrice)).enabled(true);
SalesLine_DS.object(fieldNum(SalesLine, linedisc)).enabled(true);
SalesLine_DS.object(fieldNum(SalesLine, LinePercent)).enabled(true);
SalesLine_DS.refresh();
}
}
this code enable and disable all lines not a a single line in salesline table based on agreedprice chackbox value
can anyone guide me where is the issue?
if i write the code
Sales_Line_Selected.datasource().object(fieldNum(SalesLine, SalesPrice)).enabled(true); // this line through error object reference not set to an instance of an object
i did'nt find any solution .
i also wrote code in active method and selectionchanged method of form datasource (salesline)but results are the same
thank you