Add a ttResults row

So I have a weird thing I want to do. I have a UBAQ that I will be passing in parameters for. If the query returns something, great. Get the info move on with my life. If the query doesn’t return something, I need to go and make the data that should be there. That part works fine.

What I want to do after that though, is add a row the to ttResults, so that the record that should have been there, that wasn’t, but I just created, shows up in the results. I going to be doing this using rest, so I don’t want to have to call the BAQ again to make sure that it worked, I’d rather send it once, then get back my “results”

Has anyone managed to do this? Add a row the a UBAQ’s ttResults? This is the code that I have. And it passes the context checker, but when I save the BPM it gives me an error, see below.

//this is an attempt to add the row to the results where there wasn't any. This doesn't want to 
var myNewRow = new Epicor.Customization.Bpm.ResultsUbaqRow();
myNewRow.PartXRefVend_PartNum = VendPartNum;
myNewRow.PartXRefVend_VendorNum = VendorNum;
myNewRow.PartXRefVend_PartNum = partnum;
myNewRow.Part_PartDescription = Description;
myNewRow.Part_PartNum = partnum;
myNewRow.Vendor_VendorID = (from v in Db.Vendor where v.VendorNum == VendorNum && v.Company == callContextClient.CurrentCompany select v.VendorID).FirstOrDefault();
ttResults.Add(myNewRow);

image

@Chris_Conn . this seems like the kind of thing you would do :wink:

ttResults.NewRow() ? Do i win?

Weird tho, is it compiling in designer? image

Yes you win, I just don’t get the fancy autocomplete doing it that was (boo). protip I guess, you can use

Epicor.Customization.Bpm.ResultsUbaqRow();

To get all your fields, and then add a new row and fill it in with [“field”].

Save the BPM though. That’s where it fails.

Save the BAQ or BPM? Even on BPM save no exception for me. Edit… nm i didnt have it enabled. i presume that that is some kind of dynamic class (since it’s based on the BAQ fields) and out side of the designer, the ref fails.

1 Like

Solution is to reference ResultsUbaqRow() directly without the full namespace.

var myNewRow = new ResultsUbaqRow();

2 Likes

Hi @Banderson @Chris_Conn ,

Any possibility we can add column in the ttResult based on the condition ?

TIA

You’d be better off to add a calculated column, then programmatically fill it with data.

1 Like

Hi @Chris_Conn ,

Here is the query result and I want to fill the data in a calculated field. Could you please provide an example of adding row into the query.

var queryDataSet = result.Results.ToList();
int number = queryDataSet.Count();

Thanks

foreach(var myrow in result.Results)
{
//assuming your BAQ has a nvarchar calc field called MyField
myrow.Calculated_MyField = “Hi Mom”;
}

1 Like

You just want a row count? You can do that in SQL. Just make the partition by something that is the same for all the row. Company and a common one I use.

Count(1) over (Partition by table.company)
1 Like

Thanks for your help. I have completed the task.

1 Like

Thanks for the reply, mate. I was looking for a calculation to be done and split that amount to each row by checking condition. My issue is resolved I just followed as Chris_Conn explained. Thanks Guys