web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

SysOperationFramework DataContract Error The type xxxContract is not a valid data contract.

(0) ShareShare
ReportReport
Posted on by 625

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.

I have the same question (0)
  • nmaenpaa Profile Picture
    101,162 Moderator on at

    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!

  • CRSW Profile Picture
    625 on at

    [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;
    }

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    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.

  • WillWU Profile Picture
    22,361 on at

    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.

    www.artofcreation.be/.../

    Hope this helps.

  • CRSW Profile Picture
    625 on at

    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

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans