Hi Roger,
There is another way you can do it, which might work 'in all of the cases'!
Specify the Box unit and the Pallet unit on the Unit sequence group, ensuring that you have the relevant unit conversion defined.
On the 'Pick' Location directive, set Restrict by unit on the first Location directive line. Set the Restrict by unit unit to Pallet. Select Allow split.
Create a second Location directive line, on which Restrict by unit is not selected (or, is set to Box).
With this configuration, AX will look for Locations which contain full pallets first, and create Work lines with the Pallet unit. Then it will create Work lines with the Box unit for any remaining quantity.
You can then have different Work templates for each Unit, using the Query to select which unit each Work template is for (Directive unit, I think, is the field to use).