Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How length of variable is interpreted in visual studio CIL

(0) ShareShare
ReportReport
Posted on by 10

Hi,

I have an case, where an AIF service is consumed and the variable length is 20.

Through code i am concatenating two values, and assigning to a variable with length 20. 

Consider an scenario, where the concatenation exceeds the length of 20. Ax is smart enough to truncate the values to length to 20.

But when AIF service is consuming the code, the length is not truncate the value. Tried debugging through Visual studio and found the variable does not have any length restriction on visual studio code. 

Anyone experienced something similar. If so, could someone explain what is different and how to avoid this issue.

Highly appreciate any thoughts on this behavior. Thanks in advance. 

  • Verified answer
    Martin Dráb Profile Picture
    231,788 Most Valuable Professional on at
    RE: How length of variable is interpreted in visual studio CIL

    Assuming that youre taling about strings, what you see is the documented behavior. Let me quote the documentation:

    The System.String type in .NET Framework does not have a property that corresponds to the maximum length of an X++ str, and string truncation does not occur.

    You can use functions like subStr() to take first 20 characters from a string.

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: How length of variable is interpreted in visual studio CIL

    Have you tried using a temp variable (System.String etc.)?

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,923 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,788 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans