Trying to Test a Kinetic Function with Rest

I have this function code that I need to pass a few parameters to one being a table.


using (var svc = Ice.Assemblies.ServiceRenderer.GetService<Ice.Contracts.DynamicQuerySvcContract>(context))
{

  Ice.Tablesets.DynamicQueryTableset dsQuery = svc.GetByID(baqID);

  if (baqID != null) 
  { 
    Ice.Tablesets.QueryExecutionTableset execSet = svc.GetQueryExecutionParameters(dsQuery);
    foreach (DataRow pRow in baqParameterTbl.Tables[0].Rows)
    {
      int x = 0;
      execSet.ExecutionParameter[x].ParameterID = pRow["ParameterID"].ToString(); 
      execSet.ExecutionParameter[x].ParameterValue = pRow["ParameterValue"].ToString();
      execSet.ExecutionParameter[x].IsEmpty = Convert.ToBoolean(pRow["IsEmpty"].ToString());
      x = x + 1;
      
    }
   
    baqResult = svc.Execute(dsQuery, execSet); 
  }
}
context.Dispose();

Here is how I set up the function in Function Maintenance.

Here is the attempt I made to pass a table as a function input parameter after asking CoPilot.

I searched but did not find anyway to format this parameter table as a CSV.
Anyone have any thoughts?

Don’t know if it’s your whole problem, but you misspelled parameter in your payload.

Why you keep resetting your counter to 0 every iteration?

:exploding_head:

2 Likes

I’d also just use CallService.
This keeps the security model.

CallService<Ice.Contracts.DynamicQuerySvcContract>(svc =>
{
//code here

});
2 Likes

Why not just setup a table in memory and use JsonConvert.SerializeObject(dtMyDataTable); ? The use that as your test data to your REST function?

2 Likes

Gogators Dogpile GIF by Florida Gators

But we’re here to help. Ask away.

1 Like

Ok fixed the “stupid errors”

@klincecum Sorry I had help writing this code and not fluent enough to apply your suggestion using CallService

@CSmith my plan for this function is to call it from Application Studios and wanted to test pass parameters. Should I be passing a string and parsing it instead of trying to use a table?

Thank you for your assistance, greatly appreciated

String is ok unless you’re passing a huge amount of info… Hard to tell from the information you have provided. Curious, why use a function to getBaqResult? What are you trying to do perhaps we can help?

1 Like

We are converting a ton of Customization Forms to Kinetic forms and call BAQs quite frequently. They have different numbers of parameters and whether they are required or not. We figured we could use this getBaqResult to pass parameters as a standard and have the code block build the parameters before the call.

If using application studio / a set amount of input parameters, why not add these all as separate parameters in your signature? :slight_smile:

Otherwise, I have used serialized json quite often for large amounts of data, entire dataview, etc.

Edit: noticed the ‘they have a different amount of parameters’ - definitely serialized json and parse this in your function body.

You might be able to call the BAQSvc REST endpoint. The URL contains the parameters in the query string (after the ‘?’). You would build up your parameter in a variable in TransView and then bind that when you call the BAQ.

1 Like

And if you do decide to use a function, you can browse for types and include an actual QueryExecutionDataset as a variable.

2 Likes

So I understand where you guys are going but, I think I left out one bit of info. We would be Invoking this getBAQResult in another Function that processes data before passing a dataset back to the Kinetic Application.
For an example Currently I have a customization that loads a detail grid on the bottom and then summarizes each cell in the Summary Grid at the top by Month, our Backlog. If I tried to do this in Kinetic Application Studio I would have to load the Detail Grid then pass it to the Summary Function to generate the Monthly Data. Note that the grid below is not populated for this image, sensitive data.

Each one of the Cells in the summary grid is a method that calculates against the Detail Grid One month at a time.

I tried passing a dataset to a function and have not had a lot of luck.
So I figured I could create a function that calls for the detail grid data, manipulate that data into a table, save the Summary Table, then call the summary and Detail tables to the grids on the Kinetic Application Studio Dashboard cards or whatever those “components” are called.
We are trying to use the code we have now as much as possible in code blocks as part of functions to convert.
Sorry for the novel…