Has anyone Created a BPM for Quoting to Fill in Purchasing Fields automatically on Get Details and create RFQ Suggestion?

,

I have the Quality BPM working. It fills in correct Unit Costs, Supplier pricelist, Checks Purchase direct flag and RFQ flag and QuoteQty. However, I’m having difficulty having it launch the RFQ Suggestions. That BO never get’s launched. Any thoughts?

We’re gonna need a lot more context, and welcome to the forum. :partying_face:

Our Bom’s are very large, over 600 parts. It takes our buyer days to go through a quote and verify if that part has an effective Date in that Supplier pricelist, if not, he has to check the Purchase Direct, RFQ Needed and Quotes Required. I automated all that checking and validation into a BPM. The problem is it does not fire the BO for RFQ Suggestions. I’ve been working on it and can’t seem to find the correct trigger to fire it. I also created a Post Processing Method to trigger Quote Asm / Update. But that did not work either.

Perhaps a function to do the RFQ part would work. Trigger it from your BPM and sent the relevant data to the function.

Thanks. Now we have the business reasons, now show us your work so we can help you with the technical.

This is the QUOTEMTL In Trans Data Directive. {
int rfqDays = 180;

**foreach** (var m **in** ttQuoteMtl.Where(r =>
    r.RowMod == "A" &&
    !string.IsNullOrEmpty(r.PartNum)))
{
    m.BuyIt = **true**;
    m.RFQVendQuotes = 1;

    var partInfo = Db.Part
        .Where(p => p.Company == m.Company
                 && p.PartNum == m.PartNum)
        .Select(p => new
        {
            p.IUM,
            p.PUM,
            p.UOMClassID
        })
        .FirstOrDefault();

    string partPUM = partInfo != **null** ? (partInfo.PUM ?? "").Trim() : "";
    string partUOMClassID = partInfo != **null** ? (partInfo.UOMClassID ?? "").Trim() : "";

    var primaryVendorNum = Db.PartPlant
        .Where(pp => pp.Company == m.Company
                  && pp.PartNum == m.PartNum)
        .Select(pp => pp.VendorNum)
        .FirstOrDefault();

    var latestDate = Db.VendPart
        .Where(v => v.Company == m.Company
                 && v.PartNum == m.PartNum
                 && v.EffectiveDate <= DateTime.Today
                 && (v.ExpirationDate == **null** || v.ExpirationDate >= DateTime.Today))
        .Select(v => (DateTime?)v.EffectiveDate)
        .Max();

    **if** (latestDate == **null**)
    {
        m.RFQNeeded = **true**;
        **if** (string.IsNullOrEmpty(m.RowMod)) m.RowMod = "U";
        continue;
    }

    var vp = Db.VendPart
        .Where(v => v.Company == m.Company
                 && v.PartNum == m.PartNum
                 && v.EffectiveDate == latestDate.Value
                 && (v.ExpirationDate == **null** || v.ExpirationDate >= DateTime.Today))
        .OrderBy(v => v.VendorNum == primaryVendorNum ? 0 : 1)
        .FirstOrDefault();

    **if** (vp == **null**)
    {
        m.RFQNeeded = **true**;
        **if** (string.IsNullOrEmpty(m.RowMod)) m.RowMod = "U";
        continue;
    }

    m.VendorNum = vp.VendorNum;

    **if** (vp.LeadTime > 0)
        m.LeadTime = vp.LeadTime;

    int ageDays = (DateTime.Today - latestDate.Value.Date).Days;
    m.RFQNeeded = ageDays > rfqDays;

    decimal supplierPrice = vp.BaseUnitPrice;

    string pricePerCode = (vp.PricePerCode ?? "").Trim().ToUpper();
    decimal pricePerQty = 1m;

    **if** (pricePerCode == "C")
        pricePerQty = 100m;
    **else** **if** (pricePerCode == "M")
        pricePerQty = 1000m;

    supplierPrice = supplierPrice / pricePerQty;

    string supplierUOM = partPUM;
    string quoteUOM = (m.IUM ?? "").Trim();

    decimal? convFactor = **null**;

    **if** (supplierPrice != 0m
        && supplierUOM != ""
        && quoteUOM != ""
        && supplierUOM.ToUpper() != quoteUOM.ToUpper())
    {
        var uomConvRow = Db.UOMConv
            .Where(u => u.Company == m.Company)
            .ToList()
            .Where(u =>
                (u.UOMClassID ?? "").Trim().ToUpper() == partUOMClassID.ToUpper()
                && (u.UOMCode ?? "").Trim().ToUpper() == supplierUOM.ToUpper())
            .FirstOrDefault();

        **if** (uomConvRow != **null**)
            convFactor = uomConvRow.ConvFactor;

        **if** (convFactor.HasValue && convFactor.Value != 0m)
            supplierPrice = supplierPrice / convFactor.Value;
        **else**
            m.RFQNeeded = **true**;
    }

   

    m.EstUnitCost = supplierPrice;
    m.EstMtlUnitCost = supplierPrice;

    
}

}