Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

How to Get "Extended text" custom field "TEXT1" data to "purchase order lines " Description

Posted on by 40

Dear team,

I created a custom field for "Extended Text line" in this scenario because of the character length. so, I set a new length.

   
    field(1018; "Text1"; Text[2000])
    {
        Caption = 'Text1';
    }
Home->Items->Product->Related->Item->Extended Text->New->Extended text lines->(Get the field "Text1").
pastedimage1663840315677v1.png
then activate the "Automatic Ext. Texts" in this below flow,
Home->Items->Product-> ENABLE "Automatic Ext. Texts".
pastedimage1663840845527v2.png
then it is activated to product items and it shows in "Purchase Order lines"
pastedimage1663841301982v3.png
but here showing the default "Text" from "Extended Text Line"
And, My question is how to set the Custom field "Text1" in this area.
Regards,
Nagarjun M - D365 Technical Developer
Categories:
  • RE: How to Get "Extended text" custom field "TEXT1" data to "purchase order lines " Description

    Hi Amit,

    PO line description also length issue...

    the default BASE code is

    field(11; Description; Text[100])

           {

               Caption = 'Description';

                TableRelation = IF (Type = CONST("G/L Account"), "No." = CONST(''),"System-Created Entry" = CONST(false)) "G/L Account".Name WHERE("Direct Posting" = CONST(true), "Account Type" = CONST(Posting), Blocked = CONST(false))

               ELSE

               IF (Type = CONST("G/L Account"), "System-Created Entry" = CONST(true)) "G/L Account".Name

               ELSE

               IF (Type = CONST(Item), "Document Type" = FILTER(<> "Credit Memo" & <> "Return Order")) Item.Description WHERE(Blocked = CONST(false), "Purchasing Blocked" = CONST(false))

               ELSE

               IF (Type = CONST(Item), "Document Type" = FILTER("Credit Memo" | "Return Order")) Item.Description WHERE(Blocked = CONST(false))

               ELSE

               IF (Type = CONST("Fixed Asset")) "Fixed Asset".Description

               ELSE

               IF (Type = CONST("Charge (Item)")) "Item Charge".Description

               else

               if (Type = CONST(Resource)) Resource.Name;

               ValidateTableRelation = false;

               trigger OnValidate()

               var

                   ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";

                   FindRecordMgt: Codeunit "Find Record Management";

                   ReturnValue: Text[50];

                   IsHandled: Boolean;

                   ShouldErrorForFindDescription: Boolean;

               begin

                   IsHandled := false;

                   OnBeforeValidateDescription(Rec, xRec, CurrFieldNo, IsHandled);

                   if IsHandled then

                       exit;

                   if Type = Type::" " then

                       exit;

                   if "No." <> '' then

                       exit;

                   case Type of

                       Type::Item:

                           ValidateItemDescription();

                       else begin

                               ReturnValue := FindRecordMgt.FindNoByDescription(Type.AsInteger(), Description, true);

                               if ReturnValue <> '' then begin

                                   CurrFieldNo := FieldNo("No.");

                                   Validate("No.", CopyStr(ReturnValue, 1, MaxStrLen("No.")));

                               end;

                           end;

                   end;

                   ShouldErrorForFindDescription := ("No." = '') and GuiAllowed() and ApplicationAreaMgmtFacade.IsFoundationEnabled() and ("Document Type" = "Document Type"::Order);

                   OnValidateDescriptionOnAfterCalcShouldErrorForFindDescription(Rec, xRec, ShouldErrorForFindDescription);

                   if ShouldErrorForFindDescription then

                       Error(CannotFindDescErr, Type, Description);

               end;

           }

    so, I created a new field on PO Lines

    field(1037; Description1; Text[2000])

           {

               Caption = 'Description1';

               TableRelation = IF (Type = CONST("G/L Account"), "No." = CONST(''),

                   "System-Created Entry" = CONST(false)) "G/L Account".Name WHERE("Direct Posting" = CONST(true),

                                                                                   "Account Type" = CONST(Posting),

                                                                                   Blocked = CONST(false))

               ELSE

               IF (Type = CONST("G/L Account"), "System-Created Entry" = CONST(true)) "G/L Account".Name

               ELSE

               IF (Type = CONST(Item), "Document Type" = FILTER(<> "Credit Memo" & <> "Return Order")) Item.Description WHERE(Blocked = CONST(false),

                                                                                       "Purchasing Blocked" = CONST(false))

               ELSE

               IF (Type = CONST(Item), "Document Type" = FILTER("Credit Memo" | "Return Order")) Item.Description WHERE(Blocked = CONST(false))

               ELSE

               IF (Type = CONST("Fixed Asset")) "Fixed Asset".Description

               ELSE

               IF (Type = CONST("Charge (Item)")) "Item Charge".Description

               else

               if (Type = CONST(Resource)) Resource.Name;

               ValidateTableRelation = false;

               trigger OnValidate()

               var

                   ApplicationAreaMgmtFacade: Codeunit "Application Area Mgmt. Facade";

                   FindRecordMgt: Codeunit "Find Record Management";

                   ReturnValue: Text[50];

                   IsHandled: Boolean;

                   ShouldErrorForFindDescription: Boolean;

                   CannotFindDescErr: Label 'Cannot find %1 with Description %2.\\Make sure to use the correct type.', Comment = '%1 = Type caption %2 = Description';

               begin

                   IsHandled := false;

                   OnBeforeValidateDescription(Rec, xRec, CurrFieldNo, IsHandled);

                   if IsHandled then

                       exit;

                   if Type = Type::" " then

                       exit;

                   if "No." <> '' then

                       exit;

                   case Type of

                       Type::Item:

                           ValidateItemDescription();

                       else begin

                           //ReturnValue := FindRecordMgt.FindNoByDescription(Type.AsInteger(), Description, true);

                           if ReturnValue <> '' then begin

                               CurrFieldNo := FieldNo("No.");

                               Validate("No.", CopyStr(ReturnValue, 1, MaxStrLen("No.")));

                           end;

                       end;

                   end;

                   ShouldErrorForFindDescription := ("No." = '') and GuiAllowed() and ApplicationAreaMgmtFacade.IsFoundationEnabled() and ("Document Type" = "Document Type"::Order);

                   OnValidateDescriptionOnAfterCalcShouldErrorForFindDescription(Rec, xRec, ShouldErrorForFindDescription);

                   if ShouldErrorForFindDescription then

                       Error(CannotFindDescErr, Type, Description);

               end;

           }

    FINALLY, I GOT ONE ERROR

    pastedimage1663848926953v1.png

    so, Please help me to fix the issue

    Regards,

    Nagarjun M - D365 Technical Developer

  • Suggested answer
    Amit Baru Profile Picture
    Amit Baru 3,025 on at
    RE: How to Get "Extended text" custom field "TEXT1" data to "purchase order lines " Description

    Hi,

    Write code on the event of extended Text and replace Text value to Text1.

    Regards

    Amit Sharma

    www.erpconsultors.com

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,104 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans