PartAdapter Search or ForEach Loop

I’m connecting to the PartAdapter in a customization on our Sales Order Entry form, and I need to not only look up the PartNum but also the RevisionNum. I’ve got the basics for setting up the connection…

PartAdapter adapterPart = new PartAdapter(oTrans);
adapterPart.BOConnect();

bool result = adapterPart.GetByID(edvOrdDtl.dataView[edvOrdDtl.Row][“PartNum”].ToString());

if(result)
{
//Do Something…
}

But I need a way to search for the RevisionNum. I’ve tried searching for how to do this online but can’t find anything that works or makes sense. Is there a way to do a ForEach loop or search that will return what I’m looking for? Thanks for your time and any help you can provide. Have a great day!

If you care more about the rev and it’s details than the actual part details try this: (and change to look for RevNum instead of Approved)

public string ChrisWantsTheApprovedRev(string pn)
        {
            PartRevSearchAdapter prs = new PartRevSearchAdapter(oTrans);
            prs.BOConnect();
            bool more = false;
            SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
            opts.NamedSearch.WhereClauses.Add("BaseList", "PartNum = '"+pn+"' AND Approved = TRUE");
          
            DataSet myRevs = prs.GetList(opts, out more);
            
            if (myRevs.Tables[0].Rows.Count < 1) throw new Exception("No approved revisions found for "+pn);
            string RevisionNum = myRevs.Tables[0].Rows[0]["RevisionNum"].ToString();
            prs.Dispose();

            return RevisionNum;
        }

1 Like

What are you trying to do? The part number and rev already reside in the OrderDtl table.

We setup a “Method Approved” UD field in our PartRev table, and did the same in the OrderDtl table. I’m needing to catch that UD field from the PartRev when we add a part (Lines tab) and insert that into the OrderDtl field. I need the search feature so if the user changed the Revision number on the Lines tab, the UD field will update to match that revision. Hopefully that make sense.

You should be able to accomplish the same thing with a foreign key view.

1 Like

Even though I have the Part Adapter attached, the PartRev doesn’t show up in the Parent View Name list…

See if this helps. I should have named the FKV as Part and STV as PartRev, but you get the idea.

FKV:

STV:

2 Likes

Though I was able to revamp the code sample that Chris provided, it was the FKV examples that Theodore showed that did the trick, without having to write extra code. Thanks for all the help!

1 Like