Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

InventTrans Form InventTransPosting DataSources

(0) ShareShare
ReportReport
Posted on by 793

Hello everyone,

One of our customers has got a job which changes InventTransIds in the table InventTrans by adding one-char suffix to some of them. I see that this fiel is used in multiple classes in the system and is compared with the invetntransid form other tables. So as I see such a changing can cause multiple long-term consequences.

OK. Let's not take this into account yet. After such changing customer referred to me with the problems  on the form. InventTrans. For the records of InventTrans where the InventTransId field has been changed it doesn't show the info from the 3 datasources - InventTransPostingPhysical, InventTransPostingFinancial and InventTransPostingPhysicalRevenue. All these 3 datasources are bound to the same table - InventTransPosting. InventTtans table and InventTransPosting table are related using relations on the InventTtans:

pastedimage1608711922186v1.png

Also InventTRansID, Voucher, TransDate, InventTransPostingType fields together are a unique index for the table InventTransPosting:

pastedimage1608712212089v2.png

Then I checked out what code is in init method of all three datasources. It is as following:

void init()
{
    Query   query = new Query();
    ;
    query.addDataSource(tablenum(InventTransPosting));
    query.dataSourceNo(1).addDynalink(fieldnum(InventTransPosting, Voucher),
                                      inventTrans,
                                      fieldnum(InventTrans,VoucherPhysical));

    query.dataSourceNo(1).addDynalink(fieldnum(InventTransPosting, TransDate),
                                      inventTrans,
                                      fieldnum(InventTrans,DatePhysical));

    query.dataSourceNo(1).addDynalink(fieldnum(InventTransPosting, InventTransId),
                                      inventTrans,
                                      fieldnum(InventTrans,InventTransId));

    query.dataSourceNo(1).addRange(fieldnum(InventTransPosting,InventTransPostingType)).value(queryValue(InventTransPostingType::PhysicalRevenue));

    inventTransPostingPhysicalRevenue_DS.query(query);

    super();
}

Because the InventTransID has been changed in InventTrans but it is the same as it was in InventTransPosting it can't find the related records in InventTransPosting and therefore we don't see any info in the form.

I see 2 solutions here:

1) Change InventTransPosting.InventTRansId to the same value as it is in InventTRans during the job implementation

But since the field InventTransPosting.InventTRansId is used in many othe places it can break other logic

2) Somehow change the code on the form so it will search  InventTRansId by mask

Can you pls point me to the right direction?

Thanks.

  • dark_knight Profile Picture
    793 on at
    RE: InventTrans Form InventTransPosting DataSources

    Yes. I totally agree with you. Yes. I saw that it's used in salesline and purchline and in also in InventTransPosting. Thank you.

  • Verified answer
    Martin Dráb Profile Picture
    231,760 Most Valuable Professional on at
    RE: InventTrans Form InventTransPosting DataSources

    Changing InventTransId is am terrible idea. You see one broken thing, but there could be many more. For example, do you realize that InventTransId is the primary key of sales and purch order lines? Or that it's used in tax transactions?

    The best approach is rolling the change back and restoring original the IDs. The only other option would be finding references to old values in all tables using InventTransId and changing them to new values.

    Fixing your corrupted database by some code in a form isn't feasible.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans