Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Exporting Boolean Field to .csv as an Integer

Posted on by

I am trying to export form the Sales Header Table the field "Completely Shipped" as an Integer. This field will export just fine however the program that this .csv file is importing into needs an Integer. I have tried everything I can find online to no avail. I know you can use c/al code to assign variables but this is where I am having my issue. No matter how I have tried to do this I keep getting the error "Conversion error of illegal type Boolean:=Integer"

Thank you in advance for any and all help.

Troy

*This post is locked for comments

  • Suggested answer
    Troyh Profile Picture
    Troyh on at
    RE: Exporting Boolean Field to .csv as an Integer

    Suresh,

    That made it work. I can now assign whatever I want as an Integer.

    Thank you so much for your help.

    Troy

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Exporting Boolean Field to .csv as an Integer

    You cannot set "Completely Shipped", change that row to Text and name it CompletelyShipped and assign the value to it. Check the attached image

    Ext1.png

  • Troyh Profile Picture
    Troyh on at
    RE: Exporting Boolean Field to .csv as an Integer

    Suresh,

    I feel like I am closer. My issue is that when exported to .csv it is only passing "No". I need it to pass the integer or text of 0 or 1. Here is what I have for my code, if you can help. I have declared in C/AL Globals 0 as Text and 1 as Text

    root - Export::OnBeforePassVariable()

    "Sales Header".CALCFIELDS("Completely Shipped");

    IF "Sales Header"."Completely Shipped" = FALSE THEN

    "Completely Shipped" := "0" ELSE

    "Completely Shipped" := "1";

    Troy

  • Troyh Profile Picture
    Troyh on at
    RE: Exporting Boolean Field to .csv as an Integer

    Suresh,

    I am still just not getting it. I don't know how to use the CALCFIELDS Function. I am digging into learning it.

    Thank you for all your help.

    Troy

  • Troyh Profile Picture
    Troyh on at
    RE: Exporting Boolean Field to .csv as an Integer

    Thank you Suresh. I am working on this now. I will let you know how it comes out.

    Troy

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Exporting Boolean Field to .csv as an Integer

    Completely Shipped on the Header is a flowfield, so you need to use

    "Sales Header".CALCFIELDS("Completely Shipped");

    Mark the answer which helped you to resolve the issue.

  • troyh1968 Profile Picture
    troyh1968 45 on at
    RE: Exporting Boolean Field to .csv as an Integer

    Suresh,

    Thank you for the help. I did go into C/AL Globals and add CompletelyShipped as a TEXT input as well as the field property. Now it is compiling however when the export happens it is passing a blank field. I need to assign it an integer.

    IF "Sales Header"."Completely Shipped" THEN

     CompletelyShipped:= FORMAT(0)

    ELSE

     CompletelyShipped:= FORMAT(1)

    Sorry this is probably something very simple but as I am very very new at this I am struggling.

    Troy

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Exporting Boolean Field to .csv as an Integer

    Add this in the OnBeforePassVariable trigger of the field

    IF "Sales Line"."Completely Shipped" THEN

     CompletelyShipped := FORMAT(0)

    ELSE

     CompletelyShipped := FORMAT(1);

    and in the xmlport, source type should be Text.

  • troyh1968 Profile Picture
    troyh1968 45 on at
    RE: Exporting Boolean Field to .csv as an Integer

    Suresh,

    That is what I have been trying to do but I cannot seem to get it to work.

    Troy

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Exporting Boolean Field to .csv as an Integer

    Based on the value set an integer variable and use that field as an export field instead of completely shipped.

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans