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 :
Microsoft Dynamics AX (Archived)

Conditional (Ternary) causes Operand types are not compatible

(0) ShareShare
ReportReport
Posted on by

container conResult;
str segmentNameToCheck;

segmentValueToCheck = conPeek(conResult, 1) ? conPeek(conResult, 2) : "";


The string empty causes a Warning of "Operand types are not compatible with the operator. However, I have a string on one side of = and "" on the other and do not know how to prevent the warning from being thrown.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    Put your conPeek() results to variables. You'll likely find that one of them doesn't have the type you expect.

  • Community Member Profile Picture
    on at

    conPeek Function [AX 2012] states that The conPeek function automatically converts the peeked item into the expected return type. Strings can automatically be converted into integers and real numbers, and vice versa. https://msdn.microsoft.com/en-us/library/aa618978.aspx 

    The warning alludes to the "" being the issue. The function gets a Boolean from position 1 and a string from position 2 of the container. If false, then use an empty string. I thus get the warning.

    This gives no warning

    segmentValueToCheck          = "";
    if (conPeek(conResult, 1))
    {
       segmentValueToCheck = conPeek(conResult, 2);  
    }

    Why does conditional (ternary) cause the warning?

  • Verified answer
    XB Profile Picture
    1,875 on at

    Because values to return have to be of the same type.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans