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 :
Small and medium business | Business Central, N...
Suggested Answer

How to convert data type Code to Integer?

(0) ShareShare
ReportReport
Posted on by 94

Hi Guys,

I am trying to do setrange, but my 'Primary Key Field 2 No.' is Integer data type and Data type of 'No.' is Code.

How to convert code to integer data type?

 

pastedimage1676545249539v1.png

 

Please let me know is there is any way to do this.

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,214 Super User 2026 Season 1 on at

    Please use Evaluate function

    learn.microsoft.com/.../evaluate-function

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    You idea is wrong to filter the data, you need to change your logic, or brief your requirement here.

    Thanks.

  • Suggested answer
    Govinda Kumar Profile Picture
    2,304 Moderator on at

    Hi, Prathama Deshpande.

    you can also use the SetFilter,

    ChangeLogentry.SetFilter("Primary Key Field 2 No.", '=%1', Rec."No.");

    Regards

  • Suggested answer
    DAnny3211 Profile Picture
    11,421 Super User 2026 Season 1 on at

    excuse me

    don't understand?

    what table is your Rec referring to?

    in the 'Primary Key Field 2 No.' field of the change log is the field ID entered? what does your Rec.No refer to?

    maybe the logic you are using is not quite right?

    Anyway, to convert a code to an integer use the function

    EVALUATE(varInteger,VarCode) function;

    but in your case you can do a setfilte(yourfilterfield,'%1',rec.no);

    DAniele

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,419 User Group Leader on at

    You are doing incorrect setrange - The Field Primary Key Field 2 No. stores the field no. of the table whose record is stored. You should be doing two setrange-

    1. Primary Key Field 2 No. --> Field No. in Table.

    2. Primary Key Field 2 Value --> Value that you want to filter (Rec."No.").

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,306 Super User 2026 Season 1 on at

    I think you are using the wrong field for filtering. Try using "Primary Key Field 2 Value".

    ChangeLogEntry.SetRange("Primary Key Field 2 Value", Rec."No.");

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,059 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 994 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 664 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans