Skip to main content

Notifications

Business Central forum
Suggested answer

Regarding - FieldRef.value[(Any)] - method

Posted on by 190

Hi experts ,

Hope everyone is fine...

As many of you already know that FieldRef.value[(Any)] - method that it gets the value of the field and it does some modifications in that also

So my questions is ,

Is that be applicable/possible to apply it from one page to another ?

var
MyFieldRef: FieldRef;
CustomerRecref: RecordRef;
CustomerNo: Code;
Text000: Label 'Customer name has changed to %1.';
begin
CustomerNo := '50000';
CustomerRecref.Open(18);
MyFieldRef := CustomerRecref.Field(1);
if MyFieldRef.Active then begin
MyFieldRef.Value(CustomerNo);
MyFieldRef := CustomerRecref.Field(2);
MyFieldRef.Value('Contoso');
CustomerRecref.Modify;
Message(Text000, MyFieldRef.Value);
end;
end;

In the above example they done to change the name as 'Contoso' for the no 50000. Is that possible to made some changes from one page to another and can be called without specifying customer no whereelse it should be applicable to all the customer .

I hope my question is understandable 

please help me out of this ...

Thanks & Regards,

Karthikeyani C 

Categories:
  • karthikeyani c Profile Picture
    karthikeyani c 190 on at
    RE: Regarding - FieldRef.value[(Any)] - method

    Receiving error ,

    The Production BOM Line does not exist. Identification fields and values: Production BOM No.='',Version Code='WHITEWHITE',Line No.='0'

    whereas this is my code

    action(Testing)

               {

                   Caption = 'Testing';

                   ApplicationArea = Suite;

                   ToolTip = 'Just for Testing the fieldref datatype';

                   trigger OnAction()

                   var

                       MyFieldRef: FieldRef;

                       ProdbomRecref: RecordRef;

                       ItemNo: Code[20];

                       SelectedRequisitionlines: Record "Requisition Line";

                       Text000: Label 'Variant name has changed to %1.';

                   begin

                       SelectedRequisitionlines.Reset();

                       CurrPage.SetSelectionFilter(SelectedRequisitionlines);

                       if SelectedRequisitionlines.FindSet() then

                           repeat

                               "Variant Code" += SelectedRequisitionlines."Variant Code";

                           until

                           SelectedRequisitionlines.Next() = 0;

                       ItemNo := rec."No.";

                       ProdbomRecref.Open(99000772);

                       MyFieldRef := ProdbomRecref.Field(2);

                       if MyFieldRef.Active then begin

                           MyFieldRef := ProdbomRecref.Field(3);

                           MyFieldRef.Value(Rec."Variant Code");

                           ProdbomRecref.Modify;

                           Message(Text000, MyFieldRef.Value);

                       end;

                   end;

               }

    And I'm Receiving runtime error on ProdbomRecref.Modify;---this line

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,639 Super User 2024 Season 2 on at
    RE: Regarding - FieldRef.value[(Any)] - method

    Hi, Here is a special application that does not specify the field number, I hope it can give you some hints.

    https://yzhums.com/28900/

    pastedimage1663202912802v1.png

    Thanks.

    ZHU

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,023 Moderator on at
    RE: Regarding - FieldRef.value[(Any)] - method

    Hi,

    I dont under what you mean by One page to another, but you can use the same method to change the customer's field value without providing the hardcoded values, if you on page Customer card, you can use Onaftergetrecord trigger or instead you can use Batch Processing report of any table dataitem.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,493 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans