Hi Martin,
What I want is that I want to add a field in SalesLine (CodeX), when i fill this field, i need to populate salesLine.ItemId and salesLine.Id
That's why I added this code on the modifiedField of CodeX
[ExtensionOf(FormDataFieldStr(SalesTable, SalesLine, CodeX))]
final class SalesTableFormSalesLineDS_CodeX_Extension
{
public void modified()
{
FormDataSource formDataSource = element.datasource();
SalesLine salesLine = formDataSource.cursor();
next modified();
CodeX codeX = salesLine.CodeX;
Table1 table1;
Table2 table2;
select firstOnly CodeX, Id from table2
where table2.CodeX == salesLine.CodeX
join Id from table1
where table1.Id == table2.Id
salesLine.ItemId = table2.CodeY;
formDataSource.object(fieldNum(SalesLine, ItemId)).modified();
//salesLine.CodeX = codeX;
salesLine.Id = table2.Id;
}
}
And as I said, I have these two custom tables:
Table1
Id name
-- -------
id1 name1
id2 name2
And another custom table2, the relation between table1 and tabl2 is Id
Number Id codeX codeY Field1
-------- ---- ------- ----- -------
1 id1 codex1 codey1 fieldz
2 id2 codex1 codey1 fieldz
And i made the relation between SalesLine and table2 as follows
salesLine.Id == table2.Id &&
salesLine.CodeX == table2.CodeX
Now, When I click on the drop down of CodeX in salesLine i see the following result
CodeX name Field1
------ ------ ------
codex1 name1 fieldz
codex1 name2 fieldz
1. so if I click on codex1 with name2, the modified method will be called and i expect it to populate salesLine.ItemId with codey1 and salesLine.Id with Id2 but currently it's populating salesLine.Id with Id1 instead, do i need to make the relation between salesLine and table2 as reference group?
2. If i remove this line of code from the modified method
salesLine.CodeX = codeX;
then the salesLine.CodeX stays empty after i choose a value, why?