Hi Martin or all,
What I find it hard, as beginner is actually the interconnection between those 3 or 4 classes, and all the blogs obviously explaining with their own style.
Like for example, currently I have weird error, but it is runtime error since during Build is ok. It is in my Controller class, whereby the Contract class is Null. I put the code as below:
class MyController
extends SysOperationServiceController
{
public ClassDescription caption()
{
return "Service controller";
}
public static MyController newFromArgs(Args _args)
{
MyController _Controller;
MyContract _Contract;
MyTransactionLineTbl MyTransactionLineTbl;
Query query;
_Controller = new MyController();
//initialize from args
_Controller.initializeFromArgs(_args);
//get data contract
_Contract = _Controller.getDataContractObject('MyContract);
//get record
if (_args && _args.dataset() == tableNum('MyTransactionLineTbl'))
{
MyTransactionLineTbl = _args.record();
//new query
query = new Query(queryStr(MySimpleQuery));
//add range
query.dataSourceTable(tableNum(MyTransactionLineTbl)).addRange(fieldNum(MyTransactionLineTbl, RecId)).value(queryValue(MyTransactionLineTbl.RecId));
//set query
_Contract.setQuery(query);
}
return _Controller;
}
public static void main(Args _args)
{
MyController _Controller;
;
_Controller = MyController::newFromArgs(_args);
_Controller.startOperation(query);
}
}
The error is at line _Contract.setQuery() where I put in red whereby runtime error saying "Null reference".
The Contract Class it self is like below:
[DataContractAttribute]
class MyContract
{
str packedQuery;
[DataMemberAttribute, AifQueryTypeAttribute('_packedQuery',queryStr(MySimpleQuery))]
public str parmQuery(str _packedQuery = packedQuery)
{
packedQuery = _packedQuery;
return PackedQuery;
}
public Query getQuery()
{
return new Query(SysOperationHelper::base64Decode(packedQuery));
}
public void setQuery(Query _query)
{
packedQuery = SysOperationHelper::base64Encode(_query.pack());
}
}
Can I have an advice how to resolve this ?
Thanks,