Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

X++ Job Error: Operand types are not compatible with the operator.

Posted on by 165

I'm trying to update some records in CustTable. I wanted to change the field MainContactWorker (Employee Responsible). The idea is that there will be some changes made in CustTable - Employee responsible for like 1000 customers and it would not be convenient to do this by hand.
There is a relation between CustTable and HcmWorker: CustTable.MainContactWorker == HcmWorker.RecId. And I don't really know if this is a problem. Both fields' types are the same: "int64", but the EDTs are different. However, I wrote this simple (and obviously - incorrect) job and received the following error:
JOB's code:

Static void UpdateMCW(Args _args)
{
CustTable ct;
;
While select forupdate ct where ct.MainContactWorker=="5637178326"

{
If(ct)
{
Ttsbegin;

Ct.MainContactWorker=“5637172326”;
Ct.update();

Ttscommit;
}
}
}




Error:
Description: Operand types are not compatible with the operator.
Path: \Jobs\UpdateMCW
Line: 5
Diagnostic ID: Err:1


The value given for the where clause is underlined - "5637178326".
So my question is - how can I fix this error and get the records updated?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ Job Error: Operand types are not compatible with the operator.

    Hi Nikolaos,

    Thank you for your support and its working fine

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: X++ Job Error: Operand types are not compatible with the operator.

    Your DataArea variable seems to be of type List. You can't compare a list with a string.

    Why is it a List? If you change it to DataAreaId your code will work.

    Or, if you need to be able to give a list of company ids as a parameter, you need to change your processReport method. Iterate the List, take one DataAreaId at a time, and run your select statement once for each. Or, for better performance, change your select statement to a query (with Query object) and add all the DataAreaIds as ranges to that query.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ Job Error: Operand types are not compatible with the operator.

    Thank you Mr. Andre Arnaud de Calavon, I created lookup for legal entity and I am trying to use the parameter value as selected legal entities. I used the following code

    private void lookupLegalEntity(FormStringControl    _legalEntityLookup)

    {

       Query                   query;

       QueryBuildDataSource    qbds;

       SysTableLookup          sysTableLookup;

       container cnt;

           query = new Query();

           qbds = query.addDataSource(tableNum(CompanyInfo));

           qbds.addSelectionField(fieldNum(CompanyInfo, DataArea));

           qbds.addOrderByField(fieldNum(CompanyInfo, DataArea));

           SysLookupMultiSelectGrid::lookup(query, _legalEntityLookup, _legalEntityLookup, cnt);

    }

    Contract Class

    [

       DataMemberAttribute("DataArea"),

       AifCollectionTypeAttribute("DataArea", Types::String),

       SysOperationLabelAttribute(literalStr("CompanyInfo"))

    ]

    public List parmCompany(List _DataArea = DataArea)

    {

       DataArea = _DataArea;

       return DataArea;

    }

    DP Class

    [SysEntryPointAttribute]

    public void processReport()

    {

       TaxTrans    TaxTrans;

         dataContract = this.parmDataContract() as TaxListCustomizedContract;

    ttsBegin;

    delete_from TmpTaxTransaction;

    //while   select crossCompany TaxCode from TaxTrans  where TaxTrans.DATAAREAID == ''

    while   select crossCompany TaxCode from TaxTrans  where TaxTrans.DATAAREAID == DataArea

       {

           TmpTaxTransaction.TaxAmount=TaxTrans.TaxAmount;

           TmpTaxTransaction.TaxAmount=TaxTrans.TaxBaseAmount;

           TmpTaxTransaction.TaxBaseQty=TaxTrans.TaxBaseQty;

           TmpTaxTransaction.TaxCode=TaxTrans.TaxCode;

           TmpTaxTransaction.TaxInCostPriceMST=TaxTrans.TaxInCostPriceMST;

           TmpTaxTransaction.TaxOrigin=TaxTrans.TaxOrigin;

           TmpTaxTransaction.TransDate=TaxTrans.TransDate;

           TmpTaxTransaction.insert();

       }

       ttsCommit;

    }

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: X++ Job Error: Operand types are not compatible with the operator.

    Hi Avinash,

    How did you declare your variable prTransDataArea? What object type is used here? It should be a string of at least 4 characters.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ Job Error: Operand types are not compatible with the operator.

    Hi

    I am trying use the parameter but getting the following error

    while   select crossCompany TaxCode from TaxTrans where TaxTrans.DATAAREAID == prTransDataArea

    Error

    Operand types are not compatible with the operator.

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: X++ Job Error: Operand types are not compatible with the operator.

    Hi Elena,

    Remove the quotation characters (") as this indicates the value should be interpreted as a string. Without these, it will recognize the recid value correctly.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans