I don’t know how to get by this custom C# error. I’m trying to troubleshoot by popping open a message box but I can’t get the BPM to compile with the message box.
’FakeAsyncHost’ does not contain a definition for ‘PublishInfoMessage’ and no accessible extension method ‘PublishInfoMessage’ accepting a first agrument type ‘FakeAsyncHost’ could be found (are you missing a using directive or an assembly reference?)
What do I need to include to get PublishInfoMessage to work? Do I have to put something in usings & references.
// setup message box parameters: mbp
var mbp1 = "This is my message"; // text to appear on popup
var mbp2 = Ice.Common.BusinessObjectMessageType.Information; //req'd don't change
var mbp3 = Ice.Bpm.InfoMessageDisplayMode.Individual;
var mbp4 = ""; // text that appears in popup Details button ->program field
var mbp5 = ""; // text that appears in popup Details button ->method field
// Each ShipHead (should only be 1)
foreach(var sh_row in (from tt
in ttShipHead
where tt.RowMod == "U"
select tt)) {
// Each ShipDtl
foreach(var sd_row in (from tt
in Db.ShipDtl
where tt.Company == sh_row.Company
&& tt.PackNum == sh_row.PackNum
select tt)) {
// HTTP POST to endpoint to reset the order rel meta
//Create a list of your parameters
var postParams = new List<KeyValuePair<string, object>>(){
new KeyValuePair<string, object>("db", "E10Train"),
new KeyValuePair<string, object>("company", sd_row.Company) ,
new KeyValuePair<string, object>("orderNum", sd_row.OrderNum),
new KeyValuePair<string, object>("lineNum", sd_row.OrderLine),
new KeyValuePair<string, object>("relNum", sd_row.OrderRelNum)
};
mbp1 = sd_row.Company.ToString() + " " + sd_row.OrderNum.ToString();
this.PublishInfoMessage(mbp1, mbp2, mbp3, mbp4, mbp5);
//Join KVPs into a x-www-formurlencoded string
var formString = string.Join("&", postParams.Select(x => string.Format("{0}={1}", x.Key, x.Value)));
//output: FirstParamter=FirstValue&SecondParamter=SecondValue
//Encode form string to bytes
var bytes = Encoding.UTF8.GetBytes(formString);
//Create a POST webrequest
var request = WebRequest.CreateHttp("http://our-endpoint-url-here");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = bytes.Length;
//Open request stream
Stream dataStream = request.GetRequestStream();
dataStream.Write (bytes, 0, bytes.Length);
dataStream.Close();
} // end ShipDtl foreach
} // end ShipHead foreach
Wouldn’t it be nice if there was a strategy that worked for cloud and on-prem users that logged everything to a single place that was searchable, looked for correlations among events (memory usuage, number of licenses, network speed, …), and notified you of the ones you’re interested in?
If you’re cloud based, use a UD table as a logfile.
edit
Is it possible to have the server write a file to where files are accessible by “Server Download” (or whatever the E10 program is called that lets you download files from the server)?
Like the log file that is created when Generate PO Suggestions is run. If so, would that file appear as one you could select in the “Server Download” program?
Anything’s possible. But are log files that have to be downloaded and read by “hand”, a debug methodology just a little bit better than a MessageBox, the best way to go? Will devs voluntarily download these periodically to check to make sure everything is still working? For each and every log file written to? Is that how M365 works? Salesforce? G-Suite? It’s a band-aid but is that the way we want to develop?
Not a fan of MessageBox debugging. I know we grew up on it in mnmmmn-ties but debugging tools have gotten much, much better. The biggest mindset change is monitoring for errors in production and not just during development. Users find random message boxes (even regular Error dialogs) a bit unsettling.
Also… My use of “Debugging” was really meant as “developing”. Like when you want to know the value of a variable after your code did some magic on it. I call it “debugging”, because it’s most often added during development, when things aren’t working as desired. And “not working as desired”, is pretty much the definition of a bug.
But let’s say I had a bug due to an uninitialized variable. I found out where that happened and I fixed it. I put in a bunch of message boxes to find the source and now I’ve taken them out.
But it happens again. The user emails you the error. “Can you click on Details?” “Oh, I already closed the dialog”. “Well, when it happens again, please click on Details and send it to me.”
Next time it happens, we add some logging that checks to see if the variable is initialized. We have an open window that displays the log messages in real time. We have a history of every run and can see what changes as we fixed the bug. We leave conditional logging in there to catch the uninitialized variable in the future.
Some day, the variable is not initialized. We log the error, the username running the command, and the stack trace. We present the user with a message that says, “Hey. That didn’t work out. We know where the error occurred and we’ve already sent the developer all of the details. We’ll be in contact as soon as we have a resolution.” We had a notification set up in the logging system to send an alert (configurable by urgency: email, text, pager, whatever…). We go to the logging system and we see the error. We can also see from another log super-imposed on this one what the CPU and memory was like at the time. We were also logging the number of users. Uh oh. We’ve exceeded the number of logins. A call silently failed and the variable wasn’t initialized. Hmmm. Some times bugs are environmental and tough to reproduce at the developer’s desktop with everything running locally. Explains why we say, “Hmm. It works on my environment…”
Like I said, there’s room for improvement here that would benefit both Epicor and their users.
On sales order form ( very customized for us…) I use an email direct to me catching any errors, with all the error details and more.
Also for BPM’s I log into a temp file on the server. I write state of variables at different locations in code. Helps debug if anything bizarre happens…
Are you trying to throw a msg box in a custom code box marked to run Async? If so, switch it to sync to see. Async runs off the UI thread so message box code will not compile. “’FakeAsyncHost” tells me this code block is marked as such. You will need to write to the event log if you want to debug in async mode, but i much prefer debugging in Visual Studio in sync mode first, then switch to async