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 :
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,001 Super User 2025 Season 2 on at

    Please use Evaluate function

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

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 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,397 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,380 Super User 2025 Season 2 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,284 Super User 2025 Season 2 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

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans