I have this code snippet contributed by @klincecum in C# that he was very kind to provide. However, the customization where it needs to go is written in VB and VERY extensive, would be very time-consuming to convert. If ANYONE could help me get the code below converted to VB you would be a LIFESAVER!
//References:
//All should already be in client directory. Choose all files to see them.
//Epicor.Ice.Lib.RestClient.dll
//Ice.Core.Session.dll
//Newtonsoft.Json;
using Ice.Lib.RestClient;
using Ice.Core;
using Newtonsoft.Json;
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
string restApiKey = "Your APIKEY Here";
string libraryName = "JMyers56";
string functionName = "CallBAQ";
var functionInputParameters = new RestContent(
new
{
baqName = "aaaa"
});
var restClient = new RestClientBuilder()
.SetDefaultApiKey(restApiKey)
.UseSession(oTrans.CoreSession)
.Build();
var response = restClient.Function.Post(libraryName, functionName, functionInputParameters, published: true);
var responseJson = response.GetJsonResult();
DataSet resultDS = JsonConvert.DeserializeObject<DataSet>(responseJson["baqOutput"].ToString());
epiUltraGridC1.DataSource = resultDS;
}
Imports Ice.Lib.RestClient
Imports Ice.Core
Imports Newtonsoft.Json
Private Sub epiButtonC1_Click(sender As Object, args As System.EventArgs)
Dim restApiKey As String = "Your APIKEY Here"
Dim libraryName As String = "JMyers56"
Dim functionName As String = "CallBAQ"
Dim functionInputParameters = New RestContent(
New With {
.baqName = "aaaa"
})
Dim restClient = New RestClientBuilder() _
.SetDefaultApiKey(restApiKey) _
.UseSession(oTrans.CoreSession) _
.Build()
Dim response = restClient.Function.Post(libraryName, functionName, functionInputParameters, published:=True)
Dim responseJson = response.GetJsonResult()
Dim resultDS As DataSet = JsonConvert.DeserializeObject(Of DataSet)(responseJson("baqOutput").ToString())
epiUltraGridC1.DataSource = resultDS
End Sub
No promises! AI converted this code! But it looks pretty good to me!
That’s pretty much verbatim what I just did manually.
It’s missing Option Infer On at the very top before any imports
Option Infer On
Imports Ice.Lib.RestClient
Imports Ice.Core
Imports Newtonsoft.Json
Private Sub epiButtonC1_Click(ByVal sender As Object, ByVal args As System.EventArgs)
Dim restApiKey as String = "Your APIKEY Here"
Dim libraryName as String = "JMyers56"
Dim functionName as String = "CallBAQ"
Dim functionInputParameters = New RestContent(
New With
{
.baqName = "aaaa"
})
Dim restClient = New RestClientBuilder().SetDefaultApiKey(restApiKey).UseSession(oTrans.CoreSession).Build()
Dim response = restClient.Function.Post(libraryName, functionName, functionInputParameters, published:=True)
Dim responseJson = response.GetJsonResult()
Dim resultDS as DataSet = JsonConvert.DeserializeObject(Of DataSet)(responseJson("baqOutput").ToString())
epiUltraGridC1.DataSource = resultDS
End Sub
I went to the bing icon in the top right corner. this opens bing chat. I choose balanced. I asked it to convert this code to VB. I try to give it as little as possible just to see what it will infer. I just pasted the code right after the question, and it spit this back out.