Hi
I created a service with Controller and Datacontract using SysOperationFramework
Running the Service in batch everything works fine,, but running it outside a batch I get the mentioned error: The type xxxContract is not a valid data contract.
Hi
I created a service with Controller and Datacontract using SysOperationFramework
Running the Service in batch everything works fine,, but running it outside a batch I get the mentioned error: The type xxxContract is not a valid data contract.
There's also something strange in your controller class.
In newFromArgs() method you actually launch another class. Also this could explain your issue.
newFromArgs method should return a controller class but not execute it.
Interessting is in Batch it works, removing the 'Execute business logic in CIL' flag it works as well. But running outside a batch and having the Flag for BusinessLogic in CIL activated I get the error of a non valid DataContract
Hi CRSW,
It seems that you are trying to use a type as a data contract that is not a valid data contract type.
Please refer to the following link for how to troubleshoot this issue.
Hope this helps.
The issue could be caused by having a Common type as a data member of your contract. It's not packable, so when you set it in batch, it won't work. You should use only packable types (simplified explanation: simple types such as strings and numbers)
If you use the unique key of that record (RecId, or natural key field(s)) as data member, instead of the table buffer, it should work.
[DataContractAttribute] class SetLogShipCallContract implements SysOperationValidatable { str qryStr; Common argsRecord; } public Query getQuery() { return new Query(SysOperationHelper::base64Decode(qryStr)); } public void initQuery() { Query query; QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRangeShipAdviceType; query = new Query(queryStr(SetLogShipAdviceListPage)); queryBuildDataSource = query.addDataSource(tableNum(SetLogShipAdvHeader)); SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(SetLogShipAdvHeader, WHI_ShipAdviceType)); queryBuildRangeShipAdviceType = query.dataSourceTable(tableNum(KCS_SetLogShipAdvHeader)).addRange(fieldNum(SetLogShipAdvHeader, WHI_ShipAdviceType)); queryBuildRangeShipAdviceType.value(enum2str(WHI_ShipAdviceType::CBX)); queryBuildRangeShipAdviceType.status(RangeStatus::Open); query.dataSourceTable(tableNum(KCS_SetLogShipAdvHeader)).addSortField(fieldNum(SetLogShipAdvHeader, WHI_ShipAdviceType), SortOrder::Ascending); this.setQuery(query); } [DataMemberAttribute, SysOperationControlVisibilityAttribute(false)] public Common parmArgsRecord(Common _argsRecord = argsRecord) { argsRecord = _argsRecord; return argsRecord; } [ DataMemberAttribute, AifQueryTypeAttribute('_packedQuery', queryStr(KCS_SetLogShipAdviceListPage)) ] public str parmPackedQuery(str _packedQuery = qryStr) { qryStr = _packedQuery; return qryStr; } public void setQuery(Query _query) { qryStr = SysOperationHelper::base64Encode(_query.pack()); } public boolean validate() { boolean ret; SetLogCallHeader callHeader = this.parmArgsRecord(); SetLogCallLine callLine; PurchLine purchLine; Qty openQty; ; ret = true; if (callHeader.RecId) { while select * from callLine where callLine.CallHeader == callHeader.CallId join * from purchLine where purchLine.InventTransId == callLine.PurchLine { openQty = purchLine.RemainInventPhysical; } if(openQty == 0) { SetLogLogTable::LogEntry(callHeader, "@KCS1572", Exception::Error); ret = checkFailed("@KCS1572"); } } return ret; }
class SetLogShipCallController extends SysOperationServiceController { str qryStr; } public boolean canGoBatch() { return true; } protected void dialogPostRun() { sysOperationDialog sysOperationDialog; DialogTabPage batchTab; FormRun formRun; super(); sysOperationDialog = this.dialog() as SysOperationDialog; formRun = sysOperationDialog.formRun(); batchTab = sysOperationDialog.batchDialogTabPage(); formRun.selectControl(batchTab.control()); } protected container getOriginalQuery(str queryKey, QueryName _queryName = qryStr) { container ret; ret = super(queryKey, _queryName); return ret; } protected Object initializeServiceParameter(DictMethod dictMethod, int parameterIndex) { Object ret; SetLogShipCallContract setLogShipCallContract; ret = super(dictMethod, parameterIndex); if(ret is SetLogShipCallContract) { setLogShipCallContract = ret; SetLogShipCallController::initQuery(ret); } return ret; } public LabelType parmDialogCaption(LabelType _dialogCaption = strFmt("@KCS4790")) { LabelType ret; ret = super(_dialogCaption); return ret; } [ DataMemberAttribute ,AifQueryTypeAttribute('_qryStr', '') ] public str parmQuery(str _qryStr = qryStr) { qryStr = _qryStr; return qryStr; } public boolean showBatchTab(boolean _showBatchTab = true) { boolean ret; ret = super(_showBatchTab); return ret; } public boolean showQuerySelectButton(str parameterName = qryStr) { boolean ret; ret = super(parameterName); return ret; } public boolean showQueryValues(str parameterName = '') { boolean ret = true; ret = super(parameterName); return ret; } public static Query initQuery(SetLogShipCallContract _dataContract) { Query query; QueryBuildDataSource queryBuildDataSource; QueryBuildRange queryBuildRangeShipAdvicetype; QueryBuildRange QueryBuildRangeShipAdvStatus; ; query = new Query(); queryBuildDataSource = query.addDataSource(tableNum(SetLogShipAdvHeader)); SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(SetLogShipAdvHeader, WHI_ShipAdviceType)); queryBuildRangeShipAdvicetype = query.dataSourceTable(tableNum(SetLogShipAdvHeader)).addRange(fieldNum(SetLogShipAdvHeader, WHI_ShipAdviceType)); queryBuildRangeShipAdvicetype = queryBuildDataSource.addRange(fieldnum(SetLogShipAdvHeader, WHI_ShipAdviceType)); queryBuildRangeShipAdvicetype.value(strfmt("%1", WHI_ShipAdviceType::CBX)); query.dataSourceTable(tableNum(KCS_SetLogShipAdvHeader)).addSortField(fieldNum(SetLogShipAdvHeader, WHI_ShipAdviceType), SortOrder::Ascending); QueryBuildRangeShipAdvStatus = queryBuildDataSource.addRange(fieldnum(SetLogShipAdvHeader, Status)); QueryBuildRangeShipAdvStatus.value(strfmt("!%1, !%2", SetLogShipAdvStatus::Error, SetLogShipAdvStatus::Adopted)); _dataContract.parmPackedQuery(SysOperationHelper::base64Encode(query.pack())); return query; } public static void main(Args _args) { SetLogShipCallController setLogSvcCallController; identifierName className; identifierName methodName; SysOperationExecutionMode executionMode; ; [className, methodName, executionMode] = SysOperationServiceController::parseServiceInfo(_args); setLogSvcCallController = new SetLogShipCallController(className, methodName, executionMode); setLogSvcCallController.startOperation(); } public static SetLogShipCallController newFromArgs(Args _args) { SetLogShipCallController setLogShipCallController; SetLogShipCallContract setLogShipCallContract; ; setLogShipCallController = new SetLogShipCallController(); setLogShipCallController.initializeFromArgs(_args); setLogShipCallController.showBatchTab(true); setLogShipCallContract = setLogShipCallController.getDataContractObject(); if(_args && _args.dataset()) { setLogShipCallController.parmShowDialog(true); setLogShipCallController.parmShowProgressForm(true); setLogShipCallController.parmDialogCaption("@KCS1348"); setLogShipCallContract.parmArgsRecord(_args.record()); SetLogShipCallController::initQuery(setLogShipCallContract); setLogShipCallController.canGoBatch(); _args.caller(setLogShipCallController); new MenuFunction(menuItemActionStr(SetLogPostShipAdvicesBatch), MenuItemType::Action).run(_args); } else { throw error("@KCS1193"); } return setLogShipCallController; }
Hi CRSW,
could you please share the code of your controller class and your data contract class? This way we might be able to spot the issue. Please remember to click "Use rich text formatting" -> "Insert" -> "Code" so that it formats nicely. Thanks!
André Arnaud de Cal...
292,884
Super User 2025 Season 1
Martin Dráb
231,758
Most Valuable Professional
nmaenpaa
101,156
Moderator