Hi Everyone,
I am working on building a process screen that will allow us to update our customer-salesperson assignments easily. This information is stored in the CustSalesPeople table/DAC and has not been customized (according to the DAC schema). For some reason, I am able to delete the records that I need to, but I am unable to insert any new rows. I have tried both the Insert() and Update() methods, but neither seems to be working.
I have verified that both AllowDelete and AllowInsert are true. The variable “graph” below is an instance of CustomerMaint.
My deleting logic looks like this:
//Delete all the entries of CustSalesPeople for that customer
PXResultset<CustSalesPeople> existingRecords = PXSelect<CustSalesPeople,
Where<CustSalesPeople.bAccountID, Equal<Required<CustSalesPeople.bAccountID>>>>
.Select(graph, accountToUpdate.BAccountID);
foreach (CustSalesPeople record in existingRecords)
{
graph.Caches<CustSalesPeople>().Delete(record);
}
graph.Actions.PressSave();
//Insert the new salesperson data
CustSalesPeople newRecord = new CustSalesPeople();
newRecord.BAccountID = accountToUpdate.BAccountID;
newRecord.LocationID = location.LocationID;
newRecord.SalesPersonID = salespersonID;
newRecord.CommisionPct = commissionPct;
newRecord.IsDefault = sourceItem.IsDefaultSalesperson;
graph.Caches<CustSalesPeople>().Insert(newRecord); // I have also tried Update(newRecord)
graph.Actions.PressSave();
All of the fields that I am inserting are not null, and since CustomerMaint is successfully deleting a record, I cannot understand why it cannot (or seems not to) insert a new row of data.
Am I missing something obvious? Getting pretty close to pulling my hair out on this one…
Thanks,
Aaron