Change Resource Group ID for Open Jobs

Could it be that ttResults is only populated for the BAQ view? Do I have to populate ttResults differently when I run from a Dashboard?

I does something different, but I can’t remember the exact details. I seem to remember the the BAQ returned 1 row per, but the dashboard would return the previous and updated row, so it would get double the rows if you didn’t filter it right in the BPM. But that seems opposite of what your seeing.

Could it be changing it, then changing it back?

It is still ttResults. I have never done this with a form. I simply type the new data in the grid and click save. The update runs just like it does in the BAQ.

It doesn’t seem to be changing anything. This is my messagebox.

Updated <myCount/> records!
callcontext: <callContextBpmData.ShortChar01/>
var: <NewResGrpID/>
action id: <actionID/>

You can see myCount is increased as the first line in the foreach of ttResults.

When I run in BAQ I get “Updated x records!” But in the dash view it says “Updated 0 records!”

I can’t point to form elements from a BPM custom code widget, right? I know that my epiUltraGridC1 called “V_ChangeOpenJobResGrpIDs_1View” contains the results of my BAQ. Can I somehow point to that instead of ttResults?

If it’s a one time thing, can’t you just run it from the BAQ?

Perhaps I could get away with this. It would certainly be a workaround, but I feel like we are so close to the end here, I would hate to give up now!

I think the code I used from @josecgomez for executing the custom action might be the problem.

While the code does execute the custom action, it seems to do so on an empty ttResults table.

private void BAQRunCustomAction(EpiDataView iEdv, string iActionID)
{
    BAQDataView BAQView = (BAQDataView)iEdv;
    Assembly assembly = Assembly.LoadFrom("Ice.Lib.EpiClientLib.dll");
    Type t = assembly.GetType("Ice.Lib.Framework.BAQUpdater");
    BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
    MethodInfo mi = t.GetMethod("BAQRunCustomAction", bf);
    object[] param = new object[] { BAQView, iActionID};
    mi.Invoke("Ice.Lib.Framework.BAQUpdater", param);
}

I won’t pretend I understand exactly how this little function works.

Can you see anything that would let me pass in ttResults? (the current contents of the epiUltraGridC1 might work)

Edit: I think it may be because the BAQ needs the parameter passed in to populate the ttResults. When I click button 1 I pass the parameters in through the callcontextbpm data field (pulled form the textbox). But when I execute the custom action I do not pass this parameter. This could be why ttResults is empty. How can I pass that parameter using the code above?

Well it does it on the dataview you pass in. So that dataview should contain the dataset you want to apply the changes to.
Custom actions require the results to already have been populated. That is the data passed in.

Do you have any idea why the ttResults table seems blank then?

Hmmm is the DataView you are passing actually a BAQResult which would match what the BAQ is expecting?

I see… hmm I wonder if you are having to pass a rowmod?

In your dashboard, does the custom actions not show up here?

Do you mean passing a rowmod inside my custom action code? Like in the where clause of the ttResults iterator?

No like passing in the “modified” Row that is the Row you need to / want to pass in. If that makes sense.

Just for :poop: and giggles. Can you remove the where clause from your loop once?

Or add another loop before it, just to get a count of the rows.

In the original it was !ttResults.UnChanged() as in it was changed. Now it is only looking for unchanged rows which are not passed into ttResults.

No. But I thought that was because I setup a blank dashboard with a blank tracker view. Then I added all my components manually.

I am not sure what you mean.

I actually did remove that where clause as I could tell it wasn’t needed. The BAQ processes correctly without it, but the change had no effect on the dashboard.

I think this worked for your example because you were manually clicking in the UBAQ and editing a value. I am passing in all values of the BAQ and stepping through each one to update the ResGrpIDs. I pulled the where out completely so that ALL rows of my BAQ would be processed. Does that make sense?

But why???

1 Like

I ask myself this question everyday. :crazy_face:

In this particular case, I think it was a holdover from when I tried to create a dashboard with 2 UBAQs. More than one UBAQ in a Dashboard?
I was working on that project just before I started this one, so I began the same way. Creating a blank DB (dashboard) with empty tracker view to contain everything.

After considering the ‘why’, I went back and created a new dashboard based on my uBAQ. The new DB contains a native grid view that is a summary of my uBAQ. The DB also contains an empty tracker view, so I have a place to drop my textbox (to gather the new ResGrpID), and a button to execute the custom action.

I made both the grid summary and the tracker view ‘updatabale’, and I added the action to the action button list in each.

When I run the DB, first I am prompted to fill in the parameter that is required for the uBAQ to run. After I select the Old Resource Group ID from the dropdown list, the uBAQ populates the grid summary with the few jobs/ops that I want to update.

Now I just need my custom action to run the way it does from the BAQ designer. I have tried both my epiButton, and the custom action button on the action menu. Both seem to execute the custom action because my message boxes appear. The ttResults table also seems to be populated, as I can see the values in my message boxes. However, as the action reaches the end, no records are being updated.

I have made a few edits to my customization code.

private void epiButtonC2_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		// Make sure New ID text field is populated
		if (String.IsNullOrEmpty(epiTextBoxC2.Text) == true)
		{
			 MessageBox.Show("Please enter a new Resource Group ID.");
			 return;
		}

		// set callcontextbpmdata fields to textbox values
		EpiDataView edvCallContextBpmData = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
		System.Data.DataRow edvCallContextBpmDataRow = edvCallContextBpmData.CurrentDataRow;
		edvCallContextBpmDataRow["ShortChar01"] = epiTextBoxC2.Text;

		// Run custom code to change resource group ID and desc 
		var edv = oTrans.Factory("V_ChangeOpenJobResGrpIDs_1View");
		BAQRunCustomAction(edv, "ChangeResGrpID");		
	}
	
private void BAQRunCustomAction(EpiDataView iEdv, string iActionID) //unchanged
{
    BAQDataView BAQView = (BAQDataView)iEdv;
    Assembly assembly = Assembly.LoadFrom("Ice.Lib.EpiClientLib.dll");
    Type t = assembly.GetType("Ice.Lib.Framework.BAQUpdater");
    BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
    MethodInfo mi = t.GetMethod("BAQRunCustomAction", bf);
    object[] param = new object[] { BAQView, iActionID};
    mi.Invoke("Ice.Lib.Framework.BAQUpdater", param);
}

For what its worth, I have attached the dashboard definition, along with the uBAQ. I also attached the customization for the dashboard. Is this enough to get this setup on your end? I will be happy to post all of this again once it works as expected.

ChangeResGrpID_DashTest1.dbd (244.9 KB)
App.ChangeResGrpIDs2.MainController_Customization_Custom1_CustomExport.xml (38.3 KB)

1 Like

I did it!!! Thanks to all of you that helped get me this far. Only 120 posts in! :slight_smile:
The only change I made was to go back to the BAQ and change :

!ttResults.UnChanged()
//to
ttResults.UnChanged()

Full post coming soon with updated attachments.
YAY!!!

It was a long road, but you all got me there!

The goal was to create a form that would show the user all open jobs and operations that utilize a specific Resource Group ID. When you first run the dashboard you will be prompted for the old resource group ID. This generates the list of jobs/ops to update.

Using the customization for the dashboard form, you can enter the new resource group ID and click the button to execute the custom action inside the BAQ.

This custom action doesn’t use epimagical methods, so take that into account when/if you try this yourself. If you find any major issues, please let me know!

ChangeResGrpID_DashWorking.dbd (244.6 KB)
App.ChangeResGrpIDs2.MainController_Customization_Custom1_CustomExport_Working.xml (37.0 KB)

New topic coming soon, so stay tuned as I now work this same process for the Part table side!

Although I am marking this post as the solution, I really would never have gotten here without the help of some of this forums best users:
@Banderson, @josecgomez, @knash, and @gpayne. You all are my heroes!
:heart:

3 Likes