Skip to main content

Notifications

Announcements

No record found.

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.

  • Suggested answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: How to convert data type Code to Integer?

    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.");

  • Suggested answer
    Saurav.Dhyani Profile Picture
    Saurav.Dhyani 17,965 Super User 2024 Season 2 on at
    RE: How to convert data type Code to Integer?

    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
    DAnny3211 Profile Picture
    DAnny3211 9,272 Super User 2024 Season 1 on at
    RE: How to convert data type Code to Integer?

    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
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to convert data type Code to Integer?

    Hi, Prathama Deshpande.

    you can also use the SetFilter,

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

    Regards

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How to convert data type Code to Integer?

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

    Thanks.

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,194 Super User 2024 Season 2 on at
    RE: How to convert data type Code to Integer?

    Please use Evaluate function

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans