Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Business Central forum

How to pass parameter using vs code for dynamics 365 bc ?

(0) ShareShare
ReportReport
Posted on by 339

Hello expert 

How to pass parameter using vs code for dynamics 365 bc ?

Categories:
  • SABIH Profile Picture
    339 on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    Dear christelle m ,

     finally below code has been successfully read data from respective table 

     

    action("fetch")
    {
    caption = 'Fetch';
    Promoted = true;

    PromotedCategory = Process;
    PromotedOnly = true;
    PromotedIsBig = true;
    ApplicationArea = All;
    trigger OnAction()
    var
    cutbackbatch: Record "CutBackBatchTable";
    cutbackprocess: Record "CutBackProcessTable";
    valueenter: Record "Value Entry";
    begin
    cutbackbatch.Reset();
    cutbackbatch.SETRANGE("Name", "Batch Name");
    cutbackbatch.SetFilter("Bill Code", "Bill Code");
    cutbackbatch.FindFirst();
    if cutbackbatch.FindSet then

    repeat
    cutbackprocess.INIT;

    "Bill Code" := cutbackbatch."Bill Code";
    License := cutbackbatch."License";


    cutbackprocess.Validate("Bill Code", "Bill Code");
    cutbackprocess.Validate("License", "License");
    cutbackprocess.Insert;

    until cutbackbatch.NEXT = 0;


    end;

    }
  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    You have to fix your filter and range. The filter cannot select any record, might be because your filter is incorrect.

  • SABIH Profile Picture
    339 on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    Dear  christelle m

    when i debugging showing like this

    "There is no CutBackBatchTable within the filter. Filters: Bill Code: "

    filter.PNG

  • SABIH Profile Picture
    339 on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    Dear christelle m

    thank you

    i will update you soon ,thank you for help me

  • Community Member Profile Picture
    on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    You may add it on the onAction trigger.

                  action("fetch")

                  {

                      caption = 'Fetch';

                      Promoted = true;

                      PromotedCategory = Process;

                      PromotedOnly = true;

                      PromotedIsBig = true;

                      ApplicationArea = All;

                      trigger OnAction()

                      begin

    CutBackBatch.SetRange(<Field>, <value>); <-------- add your range here

    CutBackBatch.FindFirst();

    Billcode := CutBackBatch.BillCode;

    License := CutBackBatch.License;

                      end;

  • SABIH Profile Picture
    339 on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    Dear christelle m ,

    Thank you for quick reply

    page 50106 CutBackProcessWorksheetPage

    {

       PageType = Worksheet;

       ApplicationArea = All;

       UsageCategory = Administration;

       SourceTable = CutBackProcessTable;

       Caption = 'Cutback Process';

       layout

       {

           area(Content)

           {

               field("Batch Name"; "Batch Name")

               {

                   ApplicationArea = All;

               }

               field("PostingDate"; "Posting Date")

               {

                   ApplicationArea = All;

               }

               repeater(CutbackProcess)

               {

                   field("Posting Date"; "Posting Date")

                   {

                       ApplicationArea = All;

                   }

                   field("Account Category"; "Account Category")

                   {

                       ApplicationArea = All;

                   }

                   field("Bill Code"; "Bill Code")

                   {

                       ApplicationArea = All;

                   }

                   field("Partner"; "Partner")

                   {

                       ApplicationArea = All;

                   }

                   field("License"; "License")

                   {

                       ApplicationArea = All;

                   }

                   field("Percentage"; "Percentage")

                   {

                       ApplicationArea = All;

                   }

                   field("Account"; "Account")

                   {

                       ApplicationArea = All;

                   }

                   field("Account Description"; "Account Description")

                   {

                       ApplicationArea = All;

                   }

                   field("AFE"; "AFE")

                   {

                       ApplicationArea = All;

                   }

                   field("Amount"; "Amount")

                   {

                       ApplicationArea = All;

                   }

                   field("Posted"; "Posted")

                   {

                       ApplicationArea = All;

                   }

               }

           }

       }

       actions

       {

           area(Processing)

           {

               group(Setup)

               {

                   action("Calculate")

                   {

                       Caption = 'Calculate';

                       Promoted = true;

                       PromotedCategory = Process;

                       PromotedOnly = true;

                       PromotedIsBig = true;

                       // RunObject = page "CutBackBatchPage";

                       ApplicationArea = All;

                       trigger OnAction()

                       begin

                           // Message('Please select the batch name ');

                       end;

                   }

                   action("Post")

                   {

                       Caption = 'Post';

                       Promoted = true;

                       PromotedCategory = Process;

                       PromotedOnly = true;

                       PromotedIsBig = true;

                       ApplicationArea = All;

                       trigger OnAction()

                       begin

                       end;

                   }

                   action("Print")

                   {

                       Caption = 'Print';

                       Promoted = true;

                       PromotedCategory = Process;

                       PromotedOnly = true;

                       PromotedIsBig = true;

                       ApplicationArea = All;

                       trigger OnAction()

                       begin

                       end;

                   }

                   action("Post and Print")

                   {

                       Caption = 'Post and Print';

                       Promoted = true;

                       PromotedCategory = Process;

                       PromotedOnly = true;

                       PromotedIsBig = true;

                       ApplicationArea = All;

                       trigger OnAction()

                       begin

                       end;

                   }

                   action("fetch")-----------------------------------------here am using fetch button where i can use your code

                   {

                       caption = 'Fetch';

                       Promoted = true;

                       PromotedCategory = Process;

                       PromotedOnly = true;

                       PromotedIsBig = true;

                       ApplicationArea = All;

                       trigger OnAction()

                       begin

                       end;

                   }

               }

           }

       }

    }

  • Community Member Profile Picture
    on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    If each form has different table, you just have to select the other table and get their values.

    You have to add onAfterValidate() trigger on the Batch name field and you select the table values from there. See code below.

    field("Batch Name", "Batch Name")

    {

    onBeforeValidate()

    begin

    Table.SetRange(<Field>, <value>);

    Table.FindFirst();

    Billcode := Table.BillCode;

    License := Table.License;

    end;

    }

  • SABIH Profile Picture
    339 on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    Hello christelle m ,

    actually my requirement is how to read (fetch data ) from one table to another table . So here

    Requirement is  below

    I have 2 pages-> Page 1 & Page 2.  

    Now I need to Page 1 field value in Page 2.

    To Achieve this, create a function in Page 2

    Based on data create param & Variable.

    Now in Page one declare a variable of Page2 and Call this function,Please find below screenshot when i push to fetch event should be read data from cutbackbatch table to cutback process table 

    fetchdata-_2800_1_2900_.PNG

  • Community Member Profile Picture
    on at
    RE: How to pass parameter using vs code for dynamics 365 bc ?

    Hi, where would you like to pass parameter from? what object to another object?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans