Problem
From A has 2 root datasources. One of them is a TempDB datasource. There is a display menuitem pointing to Form B.
Form B has the same 2 root datasources like Form A. Form B should use the TempDB Datasource to enable addtional functionality.
When I open Form B the regular Datasource is transferred correctly, but the TempDB datasource is not and therefore the addtional logic is not enabled.
Current implementation
[DataSource]
class MyTempDBTable
{
///
/// Init of TempDB Datasource of FormB
///
public void init()
{
super();
FormRunDataHelper callerDataHelper = element.args().caller().dataHelper();
FormDataSource callerFormDataSource = callerDataHelper.FindDataSource(tableStr(myTempDBTable));
//RecID is correctly filled
RefRecId currentRecid = callerFormDataSource.cursor().RecId;
if(callerFormDataSource && currentRecid)
{
//Add query range
SysQuery::findOrCreateRange(this.queryBuildDataSource(), fieldNum(myTempDBTable, RecId)).value(SysQuery::value(currentRecid));
//Copy content of the buffer and link it to the current buffer
MyTempDBTable myTempDBTableLocal = callerFormDataSource.cursor().data();
MyTempDBTable.linkPhysicalTableInstance(myTempDBTableLocal);
}
}
}
Runtime error on line MyTempDBTable.linkPhysicalTableInstance(myTempDBTableLocal):
Cannot execute the required database operation. The method is only applicable to TempDB table variables that are not linked to existing physical table instance
Standard code for linkPhysicalTableInstance()
[Form]
public class DMFEntityTemplateDefinitionLoadDialog extends FormRun
{
private DMFEntityTemplateDefinitionLoad entityTemplateDefinitionLoad;
public void init()
{
super();
if (this.args() == null
|| !(this.args().caller() is DMFEntityTemplateDefinitionLoad))
{
throw error(Error::wrongUseOfFunction(funcName()));
}
entityTemplateDefinitionLoad = this.args().caller();
DMFEntityTemplateDefinitionTmp.linkPhysicalTableInstance(DMFEntityTemplateDefinitionTmp::generateTmpData());
}
//more code
}
Questions
- How do I get the TempDB datasource from Form A and use it as the datasource on Form B without rebuilding the TempDB content (because it is already done for Form A and the record are not disposed)?
- Why is linkPhysicalTableInstance thowing this error?