Ok, well this was a very interesting dive.
This started here:
And he wanted to run a custom action and pass the queryResultDataset so it would work properly.
Well here is everything I found out.
First → App Studio Lies 
First I created a UBAQ, on ABCCode of course. You know, the default Test Table.
I set it so I could update Count Frequency. I then added a Custom Action called Test
.
I created a base bpm under Custom Actions, checked my condition on the action ID,
and output some debug data.
The code for that was basically a condition block to only fire if the actionID was “Test” & this code. →
var changedRows = queryResultDataset.Results.Where(x => !String.IsNullOrEmpty(x.RowMod));
var unchangedRows = queryResultDataset.Results.Where(x => String.IsNullOrEmpty(x.RowMod));
var changedRowsString = "Changed Rows:" + Environment.NewLine + JsonConvert.SerializeObject(changedRows, Formatting.Indented);
var unchangedRowsString = "Unchanged Rows:" + Environment.NewLine + JsonConvert.SerializeObject(unchangedRows, Formatting.Indented);
InfoMessage.Publish(changedRowsString + Environment.NewLine + Environment.NewLine + unchangedRowsString);
All good so far.
I then proceeded to use the wizard in app studio to create a new app.
Told it the baq was updateable and all that jazz.
It created my app, and I had two events I could look at.
- GetNew
- Update
So first things first, I thought, I’ll just copy one and change it.
So I did, I copied one, got everything pointed correctly, and found out some trash.
App Studio hides things. This is not a normal rest-erp / rest-kinetic.
There is nothing you can change here.
I mean you can try, but that will just make things worse.
Here is what the json for that looks like:
{
"id": "btn_Update_MyView",
"trigger": {
"type": "Control",
"target": "btn_Update_MyView",
"hook": "onClick"
},
"actions": [
{
"type": "dataview-set-current",
"value": "MyView"
},
{
"type": "rest-erp",
"param": {
"requestMethod": "POST",
"erpRequestMethod": "UpdateBaq",
"erpBaqArgs": {
"baqId": "abc",
"options": {
"populateDataView": true,
"updateOptions": {
"operation": "UpdateBaq",
"viewName": "MyView"
}
}
}
}
}
]
}
And here is a normal one for reference:
{
"trigger": {
"type": "Control",
"target": "btn_CustomActionTest_MyView",
"hook": "onClick"
},
"actions": [
{
"type": "dataview-set-current",
"value": "MyView"
},
{
"type": "rest-erp",
"param": {
"requestMethod": "POST",
"erpRequestMethod": "ErpPostWithDataViewProcessing",
"methodParameters": [
{
"field": "queryID",
"type": "string",
"value": "abc"
}
],
"svc": "Ice.BO.DynamicQuerySvc",
"svcPath": "GetByID"
},
"caption": "rest-kinetic"
}
],
"id": " btn_CustomActionTest_MyView",
"description": "Test Custom Action",
"customizable": true,
"disable": false
}
Anyway, those options are not exposed in App Studio, so you can’t set them.
Of course, I did not accept that, so I tried to set them myself in the json…
Started looking in the abomination of javascript, and found I could change
erpBaqArgs.options.updateOptions.operation
to UpdateBaqCustomAction
However, I could not figure out how to set the actionID. I tried everything, and the abomination was no help. If someone knows… @olga ? lol let me know.
Anyway, it doesn’t matter too much, because we can do this two other ways…
Way #1 → Kinetic-Baq widget (Has caveats lol)
Set
BAQ Id
to your BAQSet
View Name
to the dataview that holds your BAQ DataSet
Mode
to update
Then on to the BAQ Update Options →
Set
Operation
to customAction
Set
Action Id
to your Custom Action Id
Now this has a caveat. It won’t send a Before Image.
Most things will still work, as some kind of EpiMagic Voodoo will create one for you on the fly.
However, it lies, as it just copies the updated row to one without a RowMod.
That means conditions like field has changed from won’t work properly.
See:
Fortunately, there is another option…
Way #2 → Rest-Erp widget (Has some weirdness, but works fine lol)
Set
Service Name
to Ice.BO.DynamicQuerySvc
Set
Service Operation
to RunCustomActionByID
Then move on to the Method Parameters:
Set
queryID
to your BAQ
Set
actionID
to your Custom Action ID
DELETE the
queryResultDataset
parameter!! Yes, bye bye.
Move on to the Kinetic Rest Arguments:
Set
Parameter Path
to queryResultDataset
Set
Parameter Name
to Results
(almost got me lol)Set
View Name
to the dataview that holds your BAQ Data
Now for the wierdness, not really wierd, it just can’t be gotten rid of.
It will add an empty ds
object, that will not cause any issues.
It is empty because we put our queryResultDataSet
at the root, instead of inside ds.
(I can’t explain that well, don’t ask.)
Notice this one has a PROPER Before Image
Done
And that’s it. There are some other options you can play with in there, like sending all rows etc.
I’ll leave that up to y’all.