BPM to Form Code conversion help

I love the flexibility I have within a BPM to access the DB. I have become somewhat comfortable with it. I have already ran into instances where I have had to re-work a solution in custom (form) code using adapters instead of the DB access. In this case, I am trying to get a printer name, based on workstation id. What adapters would I use? Any suggestions.

Here is my BPM code:

String prntr= “??”;
var PRINT = (from WS_Row in Db.Device.With(LockHint.UpdLock) where
WS_Row.WorkStationID == Session.WorkstationID &&
WS_Row.Company == callContextClient.CurrentCompany
select WS_Row).FirstOrDefault();
if (PRINT != null)
{
prntr =PRINT.PrinterID;
}

var Result = from D in Db.Device
join P in Db.SysPrinter
on new { D.Company, D.PrinterID } //link these
equals new { P.Company, P.PrinterID } // to these
where D.WorkStationID == Session.WorkstationID
select P.NetworkPath;
prntr = Result.FirstOrDefault();

There is a printer maintenance screen run that with Tracing on and you’ll see the name of the adapter.

1 Like

OK and where might I find this elusive: Ice.Proxy.BO.SysPrinterImpl?

I assume I need to add it’s reference to my custom code

Should I refer to this YouTube video from this cool dude I know and use a BAQ to get this done easier?

SIGH… So I think in your video I see the light - I can find the SysPrinterAdapter using the Wizard. I normally manually add the references

1 Like

You can get at it using the Workstation adapter GetById method and retrieve the Device table.

@srossberg I have to get the network path of the printer so I have to actually query the printer table for that. I do use the printer name from the Workstation though to get the right printer.

<tracePacket>
  <businessObject>Ice.Proxy.BO.SysPrinterImpl</businessObject>
  <methodName>GetRows</methodName>
  <returnType>SysPrinterTableset</returnType>
  <localTime>12/14/2016 19:16:05:2219272 PM</localTime>
  <executionTime>6</executionTime>
  <parameters>
    <parameter name="whereClauseSysPrinter" type="System.String"><![CDATA[ BY PrinterID]]></parameter>
    <parameter name="pageSize" type="System.Int32"><![CDATA[100]]></parameter>
    <parameter name="absolutePage" type="System.Int32"><![CDATA[0]]></parameter>
    <parameter name="morePages" type="System.Boolean"><![CDATA[False]]></parameter>
  </parameters>
</tracePacket>

Yea I got that far but I couldn’t find the BO DLL to reference (add
reference). Ultimately I realized I could find it in Wizard but I decided
to use a BAQ

1 Like

Just an observation with your BPM code. You’ve used LockHint.UpdLock. Does it require that if you’re only reading data not writing?

Mark Damen
ERP System Manager

[cid:BVDairy-OfficialLogo_bbec4553-4e4a-43e7-baef-7ba65e6481021111111111111.png]

MarkDamen@bvdairy.co.uk
Mobile: +44 (0) 7790 806926

BV Dairy ι Wincombe Lane ι SHAFTESBURY ι Dorset ι SP7 8QD ι UK
Switchboard: +44 (0) 1747 851855
Fax: +44 (0) 1747 851002

http://www.bvdairy.co.uk/

[cid:AllAccresiationsSmaller_4bf6f6e3-ead2-41e2-b71d-38d2d164062f.jpg]

[cid:images(4)_4a6fa08f-4dbb-4b8b-bd23-476e43b9b462.jpg]

Everyone at BV Dairy would like to thank you for your custom and support in 2016. We wish you all a very Merry Christmas and a Happy New Year.

This year we will be making donations in lieu of Christmas cards and their postage to a local charity. We hope you understand and can appreciate the benefit that this will bring.

This message is intended for the use of only the person(s) (“Intended Recipient”) to whom it is addressed. It may contain information that is privileged and confidential. Accordingly any dissemination, distribution, copying or other use of this message or any of its content by any person other than the Intended Recipient may constitute a breach of civil or criminal law and is strictly prohibited. If you are not the Intended Recipient, please contact the sender as soon as possible.

I don’t believe so since we aren’t performing an update - I just figure better safe than sorry :slight_smile:

Also for anyone looking (and questioning my sanity): The first block of code is actually unused. I was looking for the printer ID but then ultimately found I needed printer network path. I leave it in there because my Epicor runs too fast (i’m kidding, or am I @josecgomez.trigemco)

Final Solution was to:
Create a shared BAQ that links the tables just like I did in my BPM code and filters WorkstationID with a parameter. I then used the video linked above from our resident Guru-In-Chief Jose Gomez to call my BAQ from code and use those results. It was WAY easier.

DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("CC_WORKSTATION_PRINTER");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("WokstationIDParam",((Ice.Core.Session)oTrans.Session).WorkstationID,"nvarchar",false,Guid.NewGuid(),"A");
dqa.ExecuteByID("CC_WORKSTATION_PRINTER",qeds);
//MessageBox.Show(dqa.QueryResults.Tables["Results"].Rows.Count.ToString());
if(dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
prntr = dqa.QueryResults.Tables["Results"].Rows[0]["SysPrinter_NetworkPath"].ToString();
}
else MessageBox.Show("No printers configured. Contact C.Conn");

I don’t know how I feel about this one… :confounded:

2 Likes

I am at a loss for….

Manasa

1 Like

Well I can’t unsay it :blush: But I did edit the post. Apologies if I’ve offended anyone. We all know Jose is a monogamous ERP solutions provider.

1 Like

I don’t know about that… I’ve been known to dabble… in other ERP’s… However once you go Epicor you can’t go back

:innocent:

Hopefully it’s not because you wake up with a headless server wrapped in newspaper on your pillow. Epicor Mafia? C’mon it’s FRIDAY!!!

God knows I needed the laugh….

M. Manasa Reddy
P: 703.471.7145 x454
manasa@euclidsys.commailto:manasa@euclidsys.com

1 Like