Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / PurchTable - populate ...
Finance forum
Suggested answer

PurchTable - populate createdBy field value at line level

Posted on by 674

Hi all,

I would like to populate createdBy field value on a form at a line level and make it searchable. 

I see that PurchTable table has createdBy field but PurchLine table does not have that value although there is a relation btw two tables.

In order to populate createdBy field on a form at a line level, what would be the best approach?

I have been thinking like 

1. create a purchLine table extension and add a new field purchLine.Createdby

2. add a method to populate the createdBy field from PurchTable using select keyword 

3. add this new field to the form to show at a purchase line level. 

would this be OK ? or are there a better way to do it?

Thank you. 

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: PurchTable - populate createdBy field value at line level

    Hi ShawnDEV,

    I don't think it makes sense to duplicate the value from PurchTable to all PurchLines. This value already exists in PurchTable so you can always read/show it from there.

  • ShawnDEV Profile Picture
    ShawnDEV 674 on at
    RE: PurchTable - populate createdBy field value at line level

    Hi,

    If I need a runnable class for the existing records in any cases, wouldn't it better to enable 'created by' property in purchLine table for new records and then run the runnable class for that standard field instead of creating a new field  (purchLine.myCreatedBy) and run the same runnable class?

    Thank you.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 288,420 Super User on at
    RE: PurchTable - populate createdBy field value at line level

    You can use a CoC method and extend the logic for the method 'initFromPurchTable()' on the PurchLine table.

    You also might need a runnable class for an initial loop on already existing purchase order lines and update your field then.

  • ShawnDEV Profile Picture
    ShawnDEV 674 on at
    RE: PurchTable - populate createdBy field value at line level

    Hi

    Ok, then how can I show createdby field value of the existing purchLine from purchTable table?

    I created a new field in the purchLine table via the extension. But I am struggling with filling the value of it from the PurchTable table. I can somehow fill the value using select keyword. But where should I add this method which fills the value of purchLine.my_createdBy field? as this field value should be seen in the PurchLineOpenOrder form and searchable, should I use formeventhandler?

    Thank you.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 288,420 Super User on at
    RE: PurchTable - populate createdBy field value at line level

    Hi ShawnDEV,

    When you enable this option, it will only work for new records. All already existing records will indeed not have the CreatedBy filled.

  • ShawnDEV Profile Picture
    ShawnDEV 674 on at
    RE: PurchTable - populate createdBy field value at line level

    Hi,

    I once changed the value of property Createdby to Yes, but the field value is "?" on all lines.. It does not show the value from the Purchase order header. That's why I am trying to find another way to show it.

    Or is there a way to avoid showing "?" values and show the actual value from purchTable table?

    Thank you.

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 288,420 Super User on at
    RE: PurchTable - populate createdBy field value at line level

    Hi ShawnDEV,

    You can create a table extension and change the value of the property CreatedBy to enable the field on the purchase order lines. The field will be then automatically polulated. If you want to search on this field, you have to consider creating an index with this field to prevent performance issues and database locks.

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,420 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans