Calling a Function from Custom code

On Swagger your message Info will show up as a header under CallContext. If you are getting 500 on Swagger there’s ssomething else wrong with your function.

1 Like

It’s not going to. It’s a miracle it gets passed back from the bpm that triggers it.

“on the side” ? I don’t see it, sorry

That link was in case you are cloud and wanted to use my dashboard to see the event logs.
No way you read that thread yet :rofl:

Are you saying that the invoke is not even working, it’s not even getting to my function ?
(that’s my belief)

If you are getting an error in swagger there is something wrong with your function or your input to your function. Messages come back in the response headers (as shown below)

1 Like

Is your function promoted (published)? Did you add your company in the Security Tab?

I thought I had seen that before, thanks for the reminder.

yes, promoted and company in security tab

btw, someone said, classic rest api is broken

I have two other functions in the same library that are being called from this same screen customization code that work

It is for certain authentication methods. However if the others work then its fine. Get it working in swagger / postman first.

If you are getting 500 error (what is the message)
What does your function look like (what is it doing)
Go to the Server and look at the Event Viewer on that 500 error it should give you more details.

Then double check the variables you are passing are not null, named correctly, are in the proper type etc.

I’d also comment out everything and just pass back a debug message first.

1 Like

okay, that helps, cuz I can see my message that I send at the top of the function in the response body…that should mean I can add more of those and see how far I am getting before failure…I would have never noticed that in the response, thanks !

1 Like

that is a good idea also…going to get this yet…thanks

I would suggest a thorough reading of this thread. Those trace logs are awesome and can be turned on / off as needed and are controlled server side.

You bastards that get to create your own traces suck.

I definitely will do that when I have more time… :wink:

but for now…

I figured out that my swagger call is now working,
so my last (??) question is can I get that entire response (with the message from PublishInfoMessage) to look at when I’m calling my function via rest in my customization code ?

then I think I’d be able to work thru this

right now I’m calling with this:
var localResult = stringResponse.GetAnonymousResult(new { output = (string)null });

Sure you are getting an anonymous object on that side so everything should be there. Mind you I don’t use the rest helper that Epicor built but I assume the headers etc are available there as well.

I don’t remember either, I used it once.

I use the RestSharp Library, it’s certainly available there.

You can run the screen in debug mode with visual studio and see what the object looks like.

Or run it through this function to get a single level for string output.

  //For Classic UI Customization
  //Single Level Object Walker
  string GetObjectProperties(object _obj, int padding = 30)
  {
    string _nl = Environment.NewLine;
    //string tab = "\t";

    string retValue = "";
    foreach (var prop in _obj.GetType().GetProperties())
    {
      try
      {
        retValue += prop.Name.PadRight(padding);

        try
        {
          retValue += prop.GetValue(_obj, null).ToString();
        }
        catch {/*Yes Jose, I sure did.*/}
        
      }
      catch {/*And I'll do it again!*/}
      retValue += _nl;
    }
    return retValue;
  }