Hi,
I created a field on SalesQuotationLine. When filled, then I want to auto populate ItemId based on some logic.
At first, i wrote the code on the modified field of the table to auto populate itemId and it worked. But the other fields that gets populated automatically when filling the ItemId manually weren't filled (like salesCategory, procurment category..etc)
So in the modified field method, after filling the ItemId, i called this.modified(fieldNum(SalesQuotationLine,ItemId));
But it still didn't work. Then i noticed there is code on the modified method of itemId on the formDatasource itself.
So I moved my auto populating code to the formDatasource level instead of table level and called the modified method of the formDatasource. And indeed, it started filling itemId and the other fields when filling this new field. But somehow it cleared the new field that i fill (it seems there is code that clears the line when calling the modified method of the form datasource) so i had to store the original value of the new field and fill it again after calling the modified method. Is there another way?
[ExtensionOf(FormDataFieldStr(SalesQuotationProjTable, SalesQuotationLine, NewField))]
final class SalesQuotationLineFDS_NewField_Extension
{
public void modified()
{
FormDataObject formDataObject = any2Object(this) as formDataObject;
FormDataSource formDataSource = formDataObject.datasource();
SalesQuotationLine salesQuotationLine = formDataSource.cursor();
NewField newField = salesQuotationLine.NewField;
next modified();
formDataSource.object(fieldNum(salesQuotationLine, ItemId)).modified();
salesQuotationLine.NewField = newField;
}
}