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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    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
    101,160 Moderator 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
    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
    297,670 Super User 2025 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
    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
    297,670 Super User 2025 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

Responsible AI policies

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

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans