Does anyone here use a purchasing configurator? I was asked if I could make a configurator that generates a different description for the sales order and for the purchase order, as well as setting the part class and purchase notes. I was able to make a configurator that set the purchasing details if configured on the purchase order, but it didn’t work if it was connected to a sales order/quote…
Are you using Document Rules to change the purchasing details? You should be able to add similar / same document rules, just referencing the OrderDtl context instead of PO.
I did, and I even had it output the target entity in a message box to make sure, but even when reconfigurating, if the part was configured first on a sales order it wouldn’t add the purchasing details. I was quite confused. I think its because buy to order forces the PO to look at the sales order for details, and the sales order isn’t changing.
Yeah I just did a quick test on this, doesn’t look like its letting me update any fields on the PODetail. Couldn’t even set the PODetail.TextComment. I’m going to keep messing with this to see if I can’t figure out why it’s locking those fields.
Where are you setting the message box? I’m thinking it might not be catching the PODetail Context Entity at all in the document rules. I added a StreamWriter to create a text file in my PODetail DocRule and it isn’t creating the file as expected.
I think I’ve got it working! So I added a bit of code to create a simple text file if the Context.Entity == “PODetail” in the document rules. My file wasn’t being generated. Then I added the same bit to the OrderDtl, and that worked, even when I was configuring from the PO Entry screen. So the document rule tied to the PODetail context was never executing it’s DocRule Actions.
Solution I found is a bit… hacky, but it works.
Create a checkbox input (invisible) named something like “POSave” in your Configurator Designer.
Set the value of the new CheckBox Input to true when you’re saving a configuration from the PO Entry screen (Context.Entity will be equal to “PODetail” on the client side). I did this by adding the below line to the “OnPageLeave” expression of the last page of my Configurator:
Finally, I used LINQ to access the PODetail row for the linked Buy-to-Order Order Line, and set the value to wht I wanted: In your OrderDtl Document Rule, add the below to an existing (or new) Rule Action:
if ( Inputs.POSave.Value )
{
var pd = Db.PODetail.Where( x =>
x.BTOOrderNum == Context.OrderNumber &&
x.BTOOrderLine == Context.OrderLineNumber )
.FirstOrDefault();
if ( pd != null )
{
pd.LineDesc = "Purchase Line Desc";
}
}
Nope, didn’t even try. I know you can set fields from other contexts, as I’ve set some OrderHed fields from the OrderDtl DocRule before.
Is the PO creation automatically triggered when the Sales Order is created from the Quote? I do something similar (just with Sales Orders) using an in-transaction Data Directive on the OrderDtl table. You could probably do something similar with the PODetail table and avoid the reconfiguration.
If there are several parts where you need alternate descriptions, you could make a UDCodeType and lookup the PO Description based on the PartNum, or if there are only a few that won’t change, just throw them in a Dictionary<string,string> with PartNum and LineDesc.