0

I would like to know if a text ends in '0000' in C/AL code, but I am not sure if I am doing something wrong or the documetned functions simply are not prensent in the version of NAV I am using (NAV 2016). String Functions in NAV In any case I would like to know how can I do this if it's not with this functions.

Text.ENDSWITH('0000'); // Does not compile, 
//no autocomplete for the ENDSWITH function either
Immac
  • 466
  • 1
  • 5
  • 16

2 Answers2

3

Article you are referring to is about AL - the language for developing extensions for Nav 2018 and Dynamics 365.

Here is the link you’re looking for https://learn.microsoft.com/en-us/dynamics-nav/text-data-type

No ENDSWITH analog though. You can use COPYSTR or DELSTR to simulate it.

Alternatively you can use .Net variable of type System.String to get access to all string functions of C#. C/AL’s text is assignable to .Net’s string.

Mak Sim
  • 2,148
  • 19
  • 30
1

you can use something like this:

IF COPYSTR(TheText,STRLEN(TheText)-4) = '0000' THEN
Erty Seidohl
  • 4,487
  • 3
  • 33
  • 45
  • Note that this will result in a run-time error if TheText is shorter than 5 characters. You should probably test for that situation first. – Jan Hoek Aug 31 '18 at 17:39