Question

Insert new row in tab "LOCATIONS" Fixed Assets FA303000

  • 24 April 2023
  • 4 replies
  • 52 views

Userlevel 3
Badge

Hi Expert.

I added 2 field this screen FA303000

Base locgic: if change value field Department and more.. then tab “Locations” insert a row into FALocationHistory table.

Now I want 2 field Warehouse and Location change value => insert new row into FALocationHistory table (behavior same field Department).

I try many solutions and overried base code but The system is still not working properly.

 

protected virtual void FixedAsset_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)

        {

            var newAsset = e.NewRow as FixedAsset;

            var oldAsset = e.Row as FixedAsset;

            if (newAsset == null) return;

            if (this.WillAccountsBeChanged(newAsset, oldAsset, out int? faAccID, out int? faSubID, out int? accDeprAccID, out int? accDeprSubID)

                && FAInnerStateDescriptor.IsAcquired(newAsset.AssetID, this)

                && !FAInnerStateDescriptor.WillBeTransferred(newAsset.AssetID, this)

                )

            {

                if (AssetDetails.Current == null)

                {

                    AssetDetails.Current = AssetDetails.Select();

                }

                if (AssetLocation.Current == null)

                {

                    AssetLocation.Current = AssetLocation.Select();

                };

                FALocationHistory newLocation = PXCache<FALocationHistory>.CreateCopy(AssetLocation.Current);

                try

                {

                    newLocation.RefNbr = null;

                    if (IsImport)

                    {

                        int? organizationID = PXAccess.GetParentOrganizationID(CurrentAsset.Current.BranchID);

                        string periodID = FinPeriodRepository.FindFinPeriodByDate(Accessinfo.BusinessDate, organizationID)?.FinPeriodID;

                        newLocation.PeriodID = periodID;

                    }

                    else

                    {

                    newLocation.PeriodID = GetTransferPeriod(newAsset.AssetID);

                    }

                    newLocation.ClassID = CurrentAsset.Current.ClassID;

                    newLocation.RevisionID = AssetDetails.Current.LocationRevID;

                    newLocation.TransactionDate = GetTransferDate(newAsset.AssetID, newLocation.PeriodID);

                    newLocation = (FALocationHistory)AssetLocation.Cache.Insert(newLocation);

                }

                finally { }

            }

        }

​​​​​​

Can you help me? Many thanks everyone.


4 replies

Userlevel 7
Badge +5

I haven’t worked with fixed assets - can you try adding an action button to the form that will allow you to add a new record to the FALocationHistory table all by itself?  Are you using Visual Studio to write this so you can debug and step through the code?  What is IsImport?

Userlevel 3
Badge

Thank @Django for your reply. Code above is base logic of Acumatica. 

 if change value field Department or Branch...etc.. then tab “Locations” insert a row into FALocationHistory table.

Now I want 2 field Warehouse and Location changed value => insert new row into FALocationHistory table (behavior same field Department).

can you show me example code insert a row into database? Thank you so much.

Badge +11

This is pretty basic information, which you could easily learn on your own by taking the available developer training.

I know, from experience, how tedious it is to take training, but it teaches the basic conventions of the Acumatica framework, and that’s important.

Good luck.

Userlevel 7
Badge

Hi @thanhaim were you able to find a solution? Thank you!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved