Functions - UI?

I have used Functions in a BPM, but I have need to access some via a UI customization. Is this possible? If so, how do I call them?

Thanks,

What version are you on?

If 10.2.600, Epicor includes a client REST helper (page 717 of the Ice User Guide). Lower (not sure if they include it), you can use any rest client and it would look like this, as an example:

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
    //API Key is included in the query param in this example. 
    var request = (HttpWebRequest)WebRequest.Create("https://{appserver}/{EpicorInstance}/api/v2/efx/{CompanyID}/{LibraryID}/{functionName}/?api-key={yourAPIKey}");
    request.Method = "POST";
    //All REST v2 requests also sent with authentication method (Token, Basic)
    //This should be Base64 encoded
    string username = "userName";
    string password = "passWord";
    string encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
    request.Headers.Add("Authorization", "Basic " + encoded);

    //Add body to correspond to request signature
    request.ContentType = "application/json";
    using(var writer = new StreamWriter(request.GetRequestStream()))
     {
        var values = new Dictionary<string, string>;
          {
            {"toEmailAddress", "someEmail@email.com"},
            {"fromEmailAddress","someOtherEmail@email.com"}, 
            {"body","This is the body"},   
            {"subject","Hello from Client Code!"}
        };
    string json = JsonConvert.SerializeObject(values);
    writer.Write(json); 
    }   
    using (var response = request.GetResponse()) 
    using (var reader = new StreamReader(response.GetResponseStream()))
    {
      var result = reader.ReadToEnd();
      epiTextBoxC1.Text = result.ToString();
    }

}
3 Likes

Currently on 10.2.500.17, will be moving to 600.x next month.