Skip to main content
Question

Insert new row in tab "LOCATIONS" Fixed Assets FA303000

  • April 24, 2023
  • 5 replies
  • 96 views

Forum|alt.badge.img

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.

5 replies

Forum|alt.badge.img+7
  • Captain II
  • April 25, 2023

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?


Forum|alt.badge.img
  • Author
  • Freshman II
  • April 25, 2023

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.


darylbowman
Captain II
Forum|alt.badge.img+15

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.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • June 14, 2023

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


  • Freshman I
  • May 8, 2025

any solution?