Skip to main content
Question

Error when creating IN Transfer programmatically.

  • November 27, 2024
  • 4 replies
  • 92 views

I am trying to create a Transfer but keep getting error”:

GL Error: The financial period cannot be specified because the branch has not been specified in the Branch box.'
However I am setting the branch. Below is a screenshot of my code. 

 

                INTransferEntry transferEntry = PXGraph.CreateInstance<INTransferEntry>();

INSite fromWarehouse = SelectFrom<INSite>.Where<INSite.siteCD.IsEqual<@P.AsString>>.View.Select(transferEntry, "MAIN");
INSite toWarehouse = SelectFrom<INSite>.Where<INSite.siteCD.IsEqual<@P.AsString>>.View.Select(transferEntry, "PROJECT");

DateTime? docDate = DateTime.Now.ToUniversalTime();
int? orgID = PXAccess.GetParentOrganizationID(1);
FinPeriod fPeriod = finPeriodRepository.GetFinPeriodByDate(docDate, orgID);


INRegister transferRegister = (INRegister)transferEntry.transfer.Cache.Insert();

INRegister transferRegister = new INRegister();
DateTime? docDate = DateTime.Now.ToUniversalTime();
int? orgID = PXAccess.GetParentOrganizationID(1);
FinPeriod fPeriod = finPeriodRepository.GetFinPeriodByDate(docDate, orgID);
transferRegister.DocType = INDocType.Transfer;
transferRegister.TranDate = docDate;
transferRegister.FinPeriodID = fPeriod.FinPeriodID;
transferRegister.TranDesc = "Entered programmatically";
transferRegister.SiteID = fromWarehouse.SiteID;
transferRegister.ToSiteID = toWarehouse.SiteID;
transferRegister.TransferType = INTransferType.OneStep;
transferRegister.Hold = false;
transferRegister.BranchID = 1;
transferEntry.transfer.Current = transferEntry.transfer.Insert(transferRegister);
transferRegister = transferEntry.transfer.Current;
transferRegister = transferEntry.transfer.Update(transferRegister);
transferEntry.Actions.PressSave();

 

I can use the exact same detail when doing this from UI and there’s no issue saving it. 

From the UI, the Branch is readonly and only gets set when choosing the Warehouse ID. 

Trying it a different way and getting the same error and this right after setting the branch. 

 

 

                INTransferEntry transferEntry = PXGraph.CreateInstance<INTransferEntry>();

INSite fromWarehouse = SelectFrom<INSite>.Where<INSite.siteCD.IsEqual<@P.AsString>>.View.Select(transferEntry, "MAIN");
INSite toWarehouse = SelectFrom<INSite>.Where<INSite.siteCD.IsEqual<@P.AsString>>.View.Select(transferEntry, "PROJECT");

DateTime? docDate = DateTime.Now.ToUniversalTime();
int? orgID = PXAccess.GetParentOrganizationID(1);
FinPeriod fPeriod = finPeriodRepository.GetFinPeriodByDate(docDate, orgID);


INRegister transferRegister = (INRegister)transferEntry.transfer.Cache.Insert();

transferEntry.transfer.SetValueExt<INRegister.siteID>(transferRegister, fromWarehouse.SiteID);
transferEntry.transfer.SetValueExt<INRegister.toSiteID>(transferRegister, toWarehouse.SiteID);
transferEntry.transfer.SetValueExt<INRegister.branchID>(transferRegister, 1);
transferEntry.transfer.SetValueExt<INRegister.finPeriodID>(transferRegister, fPeriod.FinPeriodID);
transferRegister = transferEntry.transfer.Update(transferRegister);
transferEntry.Actions.PressSave();

 

 

 

What am I doing wrong here?

 

 

 

 

4 replies

  • Freshman I
  • January 21, 2026

Did you manage to resolve this issue? I am encountering exactly the same issue when trying to create a transfer programmatically from within a webhook. 


npetrosov31
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • January 21, 2026

hi ​@mauritzv,

Are you sure on the branchID= 1? can you watch if the branch id gets a value after that and is not empty before putting the finperiod?


Forum|alt.badge.img
  • Freshman I
  • January 21, 2026

This error typically occurs because FinPeriodID is being set and validated before the Branch is fully initialized on the document. Even though BranchID is assigned in code, the Insert() call triggers defaulting/validation logic immediately, and if the financial period is populated before the branch context is applied, Acumatica raises the message:

“GL Error: The financial period cannot be specified because the branch has not been specified in the Branch box.”

Set the BranchID first, then insert the document.

Avoid setting FinPeriodID manually unless it is required. Acumatica will default the correct period based on the branch and transaction date.

If the financial period must be specified explicitly, it should be assigned after the document is inserted (and then updated), once the Branch context is established.


  • Freshman I
  • January 21, 2026

For info - In my instance, it turned out that AccessInfo.BranchID on my INTransferEntry graph instance was null. This seems to be because my code is running in a webhook using PXLoginScope. The result was that the financial period validation in the graph was failing.

I was able to resolve my issue by setting the branch ID before instantiating my graph instance, as follows:

PXLogin.SetBranchID(cBranchID);