uBAQ update UD field on approved POs

I created an updateable dashboard from a uBAQ that update a UD field (comments) on existing POs. The dashboard works as intended but after typing a comment, the user has to click save and then hit refresh to get the PO unnaproved, the comments updated and the PO reapproved . If the user doesnt hit refresh then POs remain unapproved. This lead to some frustation on the user part. To improve the user’s experience, I tried automating the refresh function using this thread: Dashboard Customization And dashboard refresh

I created a customization for this dashboard, in which I used Jose’s code and it works great in Pilot. Whenever I enter a comment and click “save”, the PO gets unapproved, the comment gets added to the UD field, the refresh function gets automatically called and the PO gets reapproved.

However, whenever I apply the same customization in the Live environment, It doesn’t work as intended. Whenever I enter a comment then click save, it goes straight to Refreshing the dashboard without unapproving the PO and adding my comments first…

What am I missing ?

Rather than a customization you can do the unapproval and reapprove behind the scenes so the user is not aware they happened. If I am doing my own update these there are in the same code block. If I am using Epicor’s update then you can do them preprocessing and post on update or just make sure the order field runs them before and after the update.

This is also a future proof way to approach.

unapprove

foreach (var ttResultsRow in queryResultDataset.Results.Where(ttResults_Row => !ttResults_Row.Unchanged()))
{
    
    POHeader = Db.POHeader.Where(POHeader_Row=> POHeader_Row.Company == Session.CompanyID && POHeader_Row.SysRowID == ttResultsRow.POHeader_SysRowID).FirstOrDefault();
    if (POHeader != null)
    {
        POHeader.Approve = false;
        POHeader.ApprovalStatus = "U";
    }
}

reapprove


 foreach (var ttResultsRow in queryResultDataset.Results.Where(ttResults_Row => !ttResults_Row.Unchanged()))
{   
    POHeader = Db.POHeader.Where(POHeader_Row=> POHeader_Row.Company == Session.CompanyID && POHeader_Row.SysRowID == ttResultsRow.POHeader_SysRowID).FirstOrDefault();
    if (POHeader != null)
    {
        POHeader.Approve = true;
        POHeader.ApprovalStatus = "A";
    }
}
3 Likes

Thanks a lot Greg, this worked perfectly!

1 Like