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

Announcements

No record found.

News and Announcements icon
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
    238,778 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Sagar Suman Profile Picture

Sagar Suman 2 Super User 2026 Season 1

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans