I’m trying to allow our Buyers to change who is assigned to Parts for each Vendor. i.e. they want to shift all parts assigned to a specific vendor to a different Buyer.
There isn’t any native way in Epicor to assign a Buyer to a Vendor, at least as far as I’ve found, so I’m trying to do this with a UBAQ to update the Buyer on all relevant PartPlant records at once.
I’ve got one that’s working for myself, but it doesn’t seem to work for another user, who is a Security Manager, so I don’t think security is the issue. (But I could be mistaken.) Looking for any ideas what may be doing wrong or missing. (I’m a novice when it comes to C# and UBAQs.)
Here’s the BAQ, which just gets a list of Vendors that are currently assigned to any PartPlant records. (Just filtering out any vendors that aren’t assigned to parts, since there’s nothing to update for those vendors.)
I’m using ‘Group By’ to return a single row for each Vendor. The ‘NewBuyer’ calculated field is just blank to start, and is what gets updated to the new BuyerID. I’ve got another BAQ populating a drop-down list to ensure only valid BuyerIDs are available to choose from.
And here’s the code that gets called on Update:
using (var txScope = IceContext.CreateDefaultTransactionScope())
{
// ttResults contains VendorNum to use in query to find parts. Get just the rows that were changed.
var ttResultQuery = ttResults
.Where(row => !string.IsNullOrEmpty(row.RowMod) && row.RowMod != "P");
// loop through each vendor row that was updated
foreach (var ttResult in ttResultQuery)
{
var ds = new Erp.Tablesets.UpdExtPartTableset();
// Find all parts with this vendor
var partPlantRows = (from row in Db.PartPlant.With(LockHint.UpdLock)
where row.Company == Session.CompanyID &&
row.VendorNum == ttResult.Vendor_VendorNum
select row);
// Set each part to new buyer setting
foreach (var PartPlant in partPlantRows)
{
PartPlant.BuyerID = ttResult.Calculated_NewBuyer;
}
Db.Validate();
txScope.Complete();
}
}
The UBAQ seems to work for me. I also put the BAQ into a Dashboard, deployed and added to the menu, and it all seems to work fine for me, but not for another user. What am I missing here? Is there some sort of security or permissions aspect that I’m not aware of? (Though I thought that Security Managers wouldn’t have security-based limitations.) Or something in the code that’s somehow user-specific?