Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Add the value of a new custom field to another related table

Posted on by 32
Hi,
I have added a custom field called Item Description to the item table as the current Description field is too short

I want the value of this field to show  (that was entered in the item card page) in the Blanket Purchase Order when I select an item


I can get it to show as a Flow field but I don't want this as it needs to be editable.  I just want to show this new field in the same way as the currrent Description shows.

Any help appreciated. Tried some trigger OnAfterGetRecord() code in the page extension of the Blanket Purchase Order but didn't work
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 64,622 Super User on at
    Add the value of a new custom field to another related table
    Personally, I do not recommend this customization because there are too many tables related to Item Description.
    Even if you add new fields and add this function to Blanket Purchase Order, only these two places are available, and the standard Item Description will still be displayed in other features. 
    In addition, this is also related to the posting code. If you assign a value of length 500 to a field of standard length 100, an error will be prompted or the first 100 characters will be automatically taken.
     
    As for the problem you mentioned, you can refer to the following way.
     
    Thanks
    ZHU
     
  • Yasas Profile Picture
    Yasas 53 on at
    Add the value of a new custom field to another related table
    In Business Central, there is a feature for extended descriptions in the Item card. I suggest you try that function to see if it fulfills your requirements.


    Best Regards,
    Yasas.
  • MartinaHawkins Profile Picture
    MartinaHawkins 32 on at
    Add the value of a new custom field to another related table
    Got it to work. Is there anything I am missing?  Description 2 is only 50 characters
     
    addafter("Item No.")
            {
                field("Item Description KGS"; Rec."Item Description KGS")
                {
                    ToolTip = 'Item Description';
                    ApplicationArea = all;
                }
            }
    trigger OnAfterGetRecord()
        begin
            SetMyStyle();
            
            Desc.reset;
            Desc.SetRange("No.", Rec."Item No.");
            If Desc.FindFirst() then begin
                rec."Item Description KGS" := Desc."Item Description KGS";
            end;

        end;

        procedure SetMyStyle()
        begin
            if (rec."Item Status KGS" = 'Risky') then
                Mystyle := 'Unfavorable' else
                Mystyle := 'Standard';
        end;

        var
            MyStyle: Text;
            Desc: Record "Item";
  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 52,275 Super User on at
    Add the value of a new custom field to another related table
    I would suggest you to use standard Description 2 field if you are not already using so you dont have to do any development.
     
     
    Back to your question :)
     
    The Item field values are copied to purchase line in a CopyFromItem function of Table 39
    You can subscribe to OnAfterAssignItemValues event/publisher and update your field.
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 8,080 User Group Leader on at
    Add the value of a new custom field to another related table
    Hi,
     
    I think you use OnValidate trigger to populate your new custom field.
     
    for old records you need to create a few code to update the new field.
     
    Best regards,
    Mohamed Amine MAHMOUDI

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans