Error While Creating Action in Sales Quotes Screen CR304500 - acumatica

I have created an Action in Sales Quotes Screen to create my "Forecast Document" (Customize Screen) and get the Forecast Document Nbr back into the Sales Quote Screen in the field "Forecast". Though the below code is working absolutely fine in other modules Like SO, PO and ARInvoice. As the Error says "Forecast document cannot be found in the system" which is not so, I can see the same document in the Forecast Document Screen. Following is my code:
#region Create Forecast
public PXAction<CRQuote> createForecast;
[PXUIField(DisplayName = "Create Forecast Doc", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
[PXProcessButton(CommitChanges = true)]
public IEnumerable CreateForecast(PXAdapter adapter)
{
CRQuote currentQuote = this.Base.Quote.Current;
if (currentQuote != null && currentQuote.QuoteNbr != null)
{
CRQuote quoteX = PXSelect<CRQuote, Where<CRQuote.quoteNbr, Equal<Current<CRQuote.quoteNbr>>>>.Select(this.Base, currentQuote.QuoteNbr);
if (quoteX != null)
{
CreateForecastMethod(quoteX);
}
}
return adapter.Get();
}
////PrivateMethod Create Forecast.
public virtual void CreateForecastMethod(CRQuote fHeader)
{
//Base.Actions.PressSave();
bool var_forecastCreated = false;
bool erroroccured = false;
string ErrMsg = "";
ForecastEntry forecastGraphObject = PXGraph.CreateInstance<ForecastEntry>();
ForecastHeader forecastHeaderObject = new ForecastHeader();
QuoteMaint currGRPH = PXGraph.CreateInstance<QuoteMaint>();
var Extension = this.Base.GetExtension<SOOrderEntry_Extension>();
try
{
forecastHeaderObject.RefDocNbr = fHeader.QuoteNbr;
forecastHeaderObject.RefDocTotal = fHeader.CuryProductsAmount;
forecastHeaderObject.DocType = "FORECAST";
forecastHeaderObject.ForecastType = "FORECAST";
forecastHeaderObject = forecastGraphObject.ForecastH.Insert(forecastHeaderObject);
forecastGraphObject.ForecastH.Current = forecastHeaderObject;
forecastGraphObject.Actions.PressSave();
var_forecastCreated = true;
}
catch (Exception e)
{
erroroccured = true;
ErrMsg = e.Message;
}
if (erroroccured)
{
// Acuminator disable once PX1053 ConcatenationPriorLocalization [Justification]
throw new PXException("Cannot create Forecast Document: " + ErrMsg);
}
else
{
if (var_forecastCreated)
{
CRQuote QORD = Base.Quote.Current;
CRQuoteExt xQuoteExt = PXCache<CRQuote>.GetExtension<CRQuoteExt>(QORD);
xQuoteExt.UsrForecastInvoice = forecastHeaderObject.RefNbr;
Base.Quote.Update(QORD); //this line gives the error
Base.Save.Press();
}
}
}
#endregion

Error document 'X' cannot be found in the system often occurs because the selector attribute can't get the record.
The first troubleshooting step is to check if the record exists in the database.
If the selector filters out the target record you will get this error. You can remove the selector attribute filter (joins and where clauses) to check if this is the root cause of the error.
[PXSelector(typeof(Search2<APRegister.refNbr,
LeftJoin<APInvoice, On<APRegister.docType, Equal<APInvoice.docType>,
And<APRegister.refNbr, Equal<APInvoice.refNbr>>>>,
Where<APRegister.docType, Equal<Optional<APRegister.docType>>,
And<APInvoiceJCExt.isJointPayees, NotEqual<True>,
And<IsSchedulable<APRegister>>>>>)]
To debug the selector filter, use Acumatica Request Profiler to obtain the final SQL request sent to database.

Related

Creating a Adjustment before Processing a (pick,pack,ship) scan

I am trying to create an Adjustment to my stock as I am scanning the item.
The code works and the adjustment is released as expected. The problem is the data is not submitted to SQL before the base method is invoked. Is there a way to force the data to be pushed to SQL before the base method is called?
I have tried adding a PXTransactionScope but after the ts.complete the data on SQL has not been updated
[PXOverride]
public virtual void ProcessLotSerialBarcode(string barcode, ProcessLotSerialBarcodeDelegate baseMethod)
{
string LotnumberWithOutPrf =// code to extract Lotnumber from QR code
//check if lot has stock
INItemLotSerial iNItemLotSerial = PXSelect<
INItemLotSerial,
Where<INItemLotSerial.lotSerialNbr, Equal<Required<INItemLotSerial.lotSerialNbr>>,
And<INItemLotSerial.inventoryID, Equal<Required<INItemLotSerial.inventoryID>>>>>
.Select(Base, Lotnumber, Base.HeaderView.Current.InventoryID);
//if there is no stock do adjustment
if (iNItemLotSerial.QtyHardAvail == 0)
{
using (PXTransactionScope ts = new PXTransactionScope())
{
INAdjustmentEntry iNAdjustmentEntryEntry = PXGraph.CreateInstance<INAdjustmentEntry>();
INRegister iNRegister = new INRegister();
iNRegister.ExtRefNbr = "N/A";
iNRegister.TranDesc = "Adjustment for Shipment: " + Base.HeaderView.Current.RefNbr;
iNRegister.Hold = false;
iNAdjustmentEntryEntry.adjustment.Insert(iNRegister);
INTran iNTran = iNAdjustmentEntryEntry.transactions.Insert();
iNTran.InventoryID = Base.HeaderView.Current.InventoryID;
iNTran.SiteID = 9;
iNTran.LocationID = 77;
iNTran.Qty = 1;
iNTran.UOM = Base.HeaderView.Current.UOM;
iNAdjustmentEntryEntry.transactions.Update(iNTran);
iNTran.LotSerialNbr = LotnumberWithOutPrf;
iNAdjustmentEntryEntry.transactions.Update(iNTran);
iNAdjustmentEntryEntry.Save.PressButton();
iNAdjustmentEntryEntry.release.Press();
iNAdjustmentEntryEntry.Save.PressButton();
iNAdjustmentEntryEntry.Cancel.PressButton();
ts.Complete(Base);
}
}
baseMethod?.Invoke(LotnumberWithOutPrf);
}

Need help carrying Sales Order user fields to Create Purchase order screen

I have a customization where I have added three user fields to the Sales Order (SO301000) screen transactions grid. I would like to set fields on the 'Create Purchase Order' screen (PO505000). I had used the POFixedDemand's 'RowSelected' event, which works fine - but that causes a problem when anyone tries to modify anything in a row - which re-triggers that event - not a desired outcome.
I've tried the 'RowInserting' and 'RowInserted' events - but they're never triggered. I'm assuming at this point that I'll have to intercept some code in the 'POCreate' BLC that creates the POFixedDemand records in the Create Purchase Order screen - but I don't really know where to start. Would I put it somewhere in the EnumerateAndPrepareFixedDemands method?
Here's the code I created which works for the RowSelected event, but is no good for when a row is modified by a user. Any help is appreciated. Thank you.
protected virtual void POFixedDemand_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
var pofd = (POFixedDemand)e.Row;
if (pofd == null) return;
var filter = Base.Filter.Current;
var ordernbr = filter.OrderNbr;
var ordertype = filter.OrderType;
var solinesplit = (SOLineSplit)PXSelect<SOLineSplit, Where<SOLineSplit.planID, Equal<Required<SOLineSplit.planID>>>>.Select(Base, pofd.PlanID);
if (solinesplit != null)
{
var soline = (SOLine)PXSelect<SOLine,
Where<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
And<SOLine.orderType, Equal<Required<SOLine.orderType>>,
And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>>.Select(Base, solinesplit.OrderNbr, solinesplit.OrderType, solinesplit.LineNbr);
if (soline != null)
{
var solineext = PXCache<SOLine>.GetExtension<SOLineExt>(soline);
pofd.VendorID = solineext.UsrVendor;
pofd.EffPrice = solineext.UsrVendorUnitCost;
pofd.ExtCost = solineext.UsrVendorExtendedCost;
//Now set the Vendor location...
var location = (Location)PXSelect<Location,
Where<Location.bAccountID, Equal<Required<Location.bAccountID>>>>.Select(Base, pofd.VendorID);
if (location != null)
{
pofd.LocationID = location.LocationID;
}
}
}
}
I'm assuming at this point that I'll have to intercept some code in
the 'POCreate' BLC
Yes you need to do something along those lines.
There's a similar answer here for initializing the POLine instead of POFixedDemand:
https://stackoverflow.com/a/37255340/7376238
With some minor adjustments, the general pattern would be:
public class POCreateExt : PXGraphExtension<POCreate>
{
public override void Initialize()
{
PXGraph.InstanceCreated.AddHandler<POOrderEntry>((graph) =>
{
graph.RowInserting.AddHandler<POFixedDemand>((sender, e) =>
{
// Initialize fields when row is inserted
POFixedDemand demand = e.Row as POFixedDemand;
demand.DACField = [initialization value];
});
graph.RowUpdating.AddHandler<POFixedDemand>((sender, e) =>
{
// Sometimes fields are updated so you need to
// hook RowUpdating too and re-initialize
POFixedDemand demand = e.NewRow as POFixedDemand;
demand.DACField = [initialization value];
});
});
}
}
What I came up with after some investigation is to override the 'EnumerateAndPrepareFixedDemands' method to set the values. Code is as follows:
public delegate IEnumerable EnumerateAndPrepareFixedDemandsDelegate(PXResultset<POFixedDemand> fixedDemands);
[PXOverride]
public IEnumerable EnumerateAndPrepareFixedDemands(PXResultset<POFixedDemand> fixedDemands, EnumerateAndPrepareFixedDemandsDelegate baseMethod)
{
foreach (PXResult<POFixedDemand> rec in fixedDemands)
{
POFixedDemand demand = rec;
var solinesplit = (SOLineSplit)PXSelect<SOLineSplit, Where<SOLineSplit.planID, Equal<Required<SOLineSplit.planID>>>>.Select(Base, demand.PlanID);
if (solinesplit != null)
{
var soline = (SOLine)PXSelect<SOLine,
Where<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
And<SOLine.orderType, Equal<Required<SOLine.orderType>>,
And<SOLine.lineNbr, Equal<Required<SOLine.lineNbr>>>>>>.Select(Base, solinesplit.OrderNbr, solinesplit.OrderType, solinesplit.LineNbr);
if (soline != null)
{
var solineext = PXCache<SOLine>.GetExtension<SOLineExt>(soline);
demand.VendorID = solineext.UsrVendor;
demand.EffPrice = solineext.UsrVendorUnitCost;
demand.ExtCost = solineext.UsrVendorExtendedCost;
//Now set the Vendor location...
var location = (Location)PXSelect<Location,
Where<Location.bAccountID, Equal<Required<Location.bAccountID>>>>.Select(Base, solineext.UsrVendor);
if (location != null)
{
demand.VendorLocationID = location.LocationID;
}
}
}
}
return baseMethod(fixedDemands);
}

How can I save a custom field on ARCashSale after the Release process is complete?

When I release a Cash Sales document, after everything verifies successfully and the GL Batch is created, I execute code which created a second GL Batch that handles other transactions related to the cash sale. After that batch is created, I want to save the second GL Batch's Ref Nbr on the Cash Sales document as well. When I try to save it, I get an error:
Here is my code overriding the normal Release process:
public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
ARCashSale cashSale = Base.Document.Current;
PXGraph.InstanceCreated.AddHandler<JournalEntry>(delegate (JournalEntry oldJournalEntry)
{
oldJournalEntry.RowPersisted.AddHandler<Batch>(delegate (PXCache sender, PXRowPersistedEventArgs e)
{
Batch oldBatch = oldJournalEntry.BatchModule.Current;
if (oldBatch != null && isCreated == false && e.Operation == PXDBOperation.Insert && e.TranStatus == PXTranStatus.Completed)
{
isCreated = true;
if (CFBSAdjustments.Select().Count > 0)
{
JournalEntry newJournalEntry = PXGraph.CreateInstance<JournalEntry>();
Batch newBatch = new Batch();
newBatch = newJournalEntry.BatchModule.Insert(newBatch);
Customer customer = PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, cashSale.CustomerID);
newBatch.Description = "Fund Entry for Cash Sales Reference " + cashSale.RefNbr;
newBatch.FinPeriodID = oldBatch.FinPeriodID;
newBatch.LedgerID = oldBatch.LedgerID;
newBatch.DateEntered = oldBatch.DateEntered;
decimal? debit = 0;
decimal? credit = 0;
foreach (CFBSCashSalesAdjustment row in CFBSAdjustments.Select())
{
GLTran tran = newJournalEntry.GLTranModuleBatNbr.Insert();
tran.SummPost = true;
tran.BranchID = cashSale.BranchID;
tran.TranType = GLTran.tranClass.Normal;
tran.TranClass = GL.Messages.RoundingDiff;
tran.LedgerID = newBatch.LedgerID;
tran.FinPeriodID = newBatch.FinPeriodID;
tran.TranDate = newBatch.DateEntered;
tran.CuryInfoID = Base.currencyinfo.Current.CuryInfoID;
tran.AccountID = row.Account;
tran.SubID = row.Subaccount;
tran.DebitAmt = row.DebitAmt;
tran.CuryDebitAmt = row.DebitAmt;
debit += row.DebitAmt;
tran.CreditAmt = row.CreditAmt;
tran.CuryCreditAmt = row.CreditAmt;
credit += row.CreditAmt;
tran.RefNbr = row.CashSalesRefNbr;
tran.TranDesc = customer.AcctCD + " - " + customer.AcctName;
newJournalEntry.GLTranModuleBatNbr.Update(tran);
}
newBatch = newJournalEntry.BatchModule.Update(newBatch);
if (GLSetup.Current.GetExtension<GLSetupExt>().UsrAutoRelease == true)
{
newJournalEntry.BatchModule.Current.Hold = false;
newJournalEntry.release.Press();
}
newJournalEntry.Save.Press();
if (isCreated)
isCreated = false;
cashSale.GetExtension<ARRegisterExt>().UsrFundBatch = newJournalEntry.BatchModule.Current.BatchNbr;
//Base.Document.Current.GetExtension<ARRegisterExt>().UsrFundBatch = newJournalEntry.BatchModule.Current.BatchNbr;
//Base.dummy_CATran.View.RequestRefresh();
Base.Document.Update(cashSale);
//TODO - Figure out why the fund batch isn't saving to the Cash Sale
Base.Actions.PressSave();
//Base.dummy_CATran.Cache.ClearQueryCache();
//Base.Persist(typeof(ARCashSale), PXDBOperation.Update);
}
}
});
});
return baseMethod(adapter);
}
I left in all of the different methods I've tried to get the ref nbr to save. I've ever tried to add a field updated handler for the BatchNbr field and force the new number in that way, but it did not work.
EDIT: I also noticed that I cannot successfully set an extended field on the Batch DAC. For example, I have the line newBatch.GetExtension<BatchExt>().ExtRefNbr = cashSale.RefNbr; to set the ref nbr in that document as well, but any time I run 'NewJournal.Press.Save()' it changes the set value of the extended field to null. If anyone knows how to set the extension field, I may be able to work with that instead to go down a different path that may do what I need.
I believe the appropriate place to perform your update is in graph ARDocumentRelease. Try something like this....
public class ARDocumentReleaseExtension : PXGraphExtension<ARDocumentRelease>
{
public override void Initialize()
{
ARSetup setup = Base.arsetup.Current;
Base.ARDocumentList.SetProcessDelegate(
delegate (List<BalancedARDocument> list)
{
List<ARRegister> newlist = new List<ARRegister>(list.Count);
foreach (BalancedARDocument doc in list)
{
newlist.Add(doc);
}
ARDocumentRelease.ReleaseDoc(newlist, true);
CreateSecondBatch(newlist);
}
);
Base.ARDocumentList.SetProcessCaption(PX.Objects.AR.Messages.Release);
Base.ARDocumentList.SetProcessAllCaption(PX.Objects.AR.Messages.ReleaseAll);
}
private void CreateSecondBatch(List<ARRegister> docs)
{
foreach(BalancedARDocument register in docs)
{
if (register.DocType == ARDocType.CashSale)
{
//create the second batch and assign the 2nd ref nbr to the cash sale user field
}
}
}
}

PXProcessing SetError not showing in UI Grid

This my process screen:
as you can see it throws errors but it doesnt indicate the error mark on the grid.
After clicking the process button, it just unchecks the checkbox in my records
i want the grid to be like this(with the red 'x' mark):
this is my graph :
public PXCancel<PayrollFilter> Cancel;
public PXSetup<PayrollSetup> PayrollSetup;
public PXFilter<PayrollFilter> Filter;
[PXFilterable]
public PXFilteredProcessingJoin<PayrollEmployeeProcess, PayrollFilter,
InnerJoin<EPEmployee,
On<PayrollEmployee.employeeID, Equal<EPEmployee.bAccountID>>,
InnerJoin<Branch,
On<EPEmployee.parentBAccountID, Equal<Branch.bAccountID>>>>,
Where<PayrollEmployee.payPeriodID, Equal<Current<PayrollFilter.payPeriodID>>,
And<Branch.branchID, Equal<Current<AccessInfo.branchID>>>>> EmployeePayrollProcess;
#region Constructor
public PayrollProcess()
{
PayrollSetup setup = PayrollSetup.Current;
EmployeePayrollProcess.SetSelected<PayrollEmployeeProcess.selected>();
EmployeePayrollProcess.SetProcessDelegate(delegate (List<PayrollEmployeeProcess> employees)
{
if (Filter.Current == null) return;
var payPeriod = Filter.Current.PayPeriodID ?? 0;
var payrollPeriod = Filter.Current.PayrollPeriodID ?? 0;
if (payPeriod == 0 || payrollPeriod == 0) return;
PXLongOperation.StartOperation(this, delegate ()
{
bool errorOccured = false;
foreach (PayrollEmployeeProcess employee in employees)
{
PayrollRegisterEntry graph = PXGraph.CreateInstance<PayrollRegisterEntry>();
try
{
graph.ProcessPayroll(employee, payPeriod, payrollPeriod);
PXProcessing<PayrollEmployeeProcess>.SetInfo("Employee processed");
}
catch (Exception ex)
{
errorOccured = true;
//employees.IndexOf(employee),
PXProcessing<PayrollEmployeeProcess>.SetError(ex);
}
finally
{
graph.Clear();
}
}
if (errorOccured) throw new PXException("At least one employee was not processed.");
});
});
// EmployeePayrollProcess.
}`
can anyone can help me? I'm using Acumatica 6
Throwing an exception in Acumatica sets the error in the header. To set a Row or Field level error you need to set/raise it. There's a few ways to set/raise errors, what they have in common is that they don't use the 'throw' keyword.
For a processing screen with a filter, use the following syntax to raise the error:
PXFilteredProcessing<GridDetailDAC, GridFilterDAC>.SetError(rowIndex, new PXSetPropertyException("Error Message", PXErrorLevel.RowError));
Processing screen without filter:
PXProcessing.SetError(rowIndex, new PXException("Error Message"));

How to create an Employee with an Action

I'm trying to create an Employee with an action.
I have identified the minimum required fields in the UI as:
- EmployeeID (key field)
- LastName (Contact DAC)
- Employee class
- Department
I initially tried to enter those values only expecting that SetValueExt would run the default events and assign other requested fields, but after running the action I got different messages requesting those additional fields. So I included them as well.
My code is looking as follows:
public PXAction<EPEmployee> testAction;
[PXButton]
[PXUIField(DisplayName = "EXTENDED")]
protected virtual IEnumerable TestAction(PXAdapter adapter)
{
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
employeeMaintGraph.Clear();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "CODED";
epEmployeeRow.AcctName = "employee";
epEmployeeRow.Status = "A";
employeeMaintGraph.Employee.Insert(epEmployeeRow);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.vendorClassID>(epEmployeeRow, "EMPDEFAULT");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.classID>(epEmployeeRow, "EMPDEFAULT");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.departmentID>(epEmployeeRow, "ADMIN");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.positionLineCntr>(epEmployeeRow, 1);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.consolidateToParent>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.allowOverrideCury>(epEmployeeRow, true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.allowOverrideRate>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.payToParent>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.acctName>(epEmployeeRow, "employee");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.vendor1099>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxAgency>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.updClosedTaxPeriods>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxReportRounding>(epEmployeeRow, "R");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxUseVendorCurPrecision>(epEmployeeRow, true);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxReportFinPeriod>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.taxPeriodType>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.enableTaxStartDate>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.landedCostVendor>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.isLaborUnion>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.lineDiscountTarget>(epEmployeeRow, "E");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.ignoreConfiguredDiscounts>(epEmployeeRow, false);
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATReversalMethod>(epEmployeeRow, "D");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATInputTaxEntryRefNbr>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.sVATOutputTaxEntryRefNbr>(epEmployeeRow, "M");
employeeMaintGraph.CurrentEmployee.Cache.SetValueExt<EPEmployee.type>(epEmployeeRow, "EP");
employeeMaintGraph.CurrentEmployee.Update(epEmployeeRow);
Contact contactRow = new Contact();
contactRow.LastName = "lastname";
employeeMaintGraph.Contact.Insert(contactRow);
Address addressRow = new Address();
addressRow.CountryID = "US";
employeeMaintGraph.Address.Insert(addressRow);
employeeMaintGraph.Actions.PressSave();
return adapter.Get();}
With this current version I get the message:
"Error: 'Branch' cannot be empty. Error: 'Default Location' cannot be empty. Error: 'Route Emails' cannot be empty."
I have looked for the Branch field in the database in BAccount, Employee, Vendor (employee DAC inherits from it), contact and Address tables with no luck.
Any idea what the error may be?
Thanks.
Refer to the code snippet below for an example to create an Employee within an action:
public PXAction<EPEmployee> CreateEmployee;
[PXButton]
[PXUIField(DisplayName = "Create Employee")]
protected void createEmployee()
{
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "EMPLOYEE1";
epEmployeeRow = employeeMaintGraph.Employee.Insert(epEmployeeRow);
Contact contactRow = employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select();
contactRow.FirstName = "John";
contactRow.LastName = "Green";
employeeMaintGraph.Contact.Update(contactRow);
Address addressRow = employeeMaintGraph.Address.Current = employeeMaintGraph.Address.Select();
addressRow.CountryID = "US";
addressRow = employeeMaintGraph.Address.Update(addressRow);
addressRow.State = "DC";
employeeMaintGraph.Address.Update(addressRow);
epEmployeeRow.VendorClassID = "EMPSTAND";
epEmployeeRow.DepartmentID = "FINANCE";
employeeMaintGraph.Employee.Update(epEmployeeRow);
employeeMaintGraph.Actions.PressSave();
throw new PXRedirectRequiredException(employeeMaintGraph, null);
}

Resources