Question

Programmatically Generate Wave Pick List

  • 13 April 2021
  • 0 replies
  • 192 views

Userlevel 4
Badge

Good day,

I would like to programmatically generate a Wave Pick List from the Create and Print Pick List (SO50305) screen.

The idea is to fire off a push notification whenever a wave pick list’s status changes to picking, and then consume this notification in a webhook handler.

I’ve managed to get the push notification setup, and the webhook handler is receiving the notifications nicely. So far I’ve managed to get some nice authentication working in the webhook handler (following the concepts in this webhook example), but I’m a little out of my depths w.r.t. how to actually achieve the goal of programmatically generating a wave picklist.

From what I can gather, I would need to do 3 things in order to get this working:

  1. Set the SOPickingWorksheetProcess.HeaderFilter & SOPickingWorksheetProcess.HeaderSettings values (in such a way that subsequent requests/processes can pick the values up), so that the applicable shipments are filtered, and the number of pickers + totes are populated, etc.
  2. ‘Select’ a certain number of shipments which should be processed/included in the work sheet from the greater list of shipments which would have been returned by the filter. Ideall I would like to go with 4 shipments at a time.
  3. Trigger the ‘Process’ so that the work sheet can be created.

As a side question, does my approach in using Push Notifications & Webhooks make sense? Idea is to always have a fresh batch of Pick Lists generated when picking staff in the warehouse start picking a list, but we should never generate too many in advance (as we want to include some logic in near future to cater for things like Express Shipping), which means we can’t just generate these using the Automation Schedules on a time interval basis.

Any and all help will be highly appreciated.

I have the following code in place already:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Results;
using Newtonsoft.Json;
using PX.Common;
using PX.Data;
using PX.Data.Webhooks;
using PX.Objects;
using PX.Objects.SO;
using SHPNW.Helpers;

namespace SHPNW
{
public class WavePickListAutomationHandler : IWebhookHandler
{
public async Task<System.Web.Http.IHttpActionResult> ProcessRequestAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
var ok = new OkResult(request);

using (var scope = GetAdminScope())
{
try
{
// Deserialize JSON into our Notification class
var notification = JsonConvert.DeserializeObject<NotificationMessage>(await request.Content.ReadAsStringAsync());

// No changes to make, lets exit
if (notification == null || (notification?.Inserted?.Count ?? 0) < 1)
{
return ok;
}

// Authorization Check
var secret = string.Empty;

if (request.Headers.TryGetValues("AcuAuth", out IEnumerable<string> headerValues))
{
secret = headerValues.FirstOrDefault();
}

var queryHash = HashHelper.ComputeSha256Hash(notification.Query).ToUpper();

// If secret does not match we reject the notification
if (secret != queryHash)
{
return new StatusCodeResult(System.Net.HttpStatusCode.Unauthorized, request);
}

// Use the Create & Print Pick Lists graph to generate the next wave.
var graph = PXGraph.CreateInstance<SOPickingWorksheetProcess>();
var filter = graph.Filter;

// Here I would need to set the values on the filter

// Here I would need to 'select' 4 shipments from the filtered list of shipments.

// Here I would need to 'trigger' the Process button.

}
catch (Exception ex)
{
var failed = new ExceptionResult(ex, false, new DefaultContentNegotiator(), request, new[] { new JsonMediaTypeFormatter() });
return failed;
}
}

return ok;
}

private IDisposable GetAdminScope()
{
var userName = "admin";
if (PXDatabase.Companies.Length > 0)
{
var company = PXAccess.GetCompanyName();
if (string.IsNullOrEmpty(company))
{
company = PXDatabase.Companies[0];
}
userName = userName + "@" + company;
}
return new PXLoginScope(userName);
}
}
}

 


0 replies

Be the first to reply!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved