Exception has been thrown by the target of an invocation in BPM Form

I feel like I spend most of my life on this website now…

I recently created this BPM form to show my BAQ. Originally, I had this named IndentedBOM, but now my company wants our naming scheme to be DA-IndentedBOM, or to include our company initials before everything.

The code worked fine before, but now when I am copying it over and renaming things, I am getting this error.

It looks like it is separating out the name of my form and I am not sure why.

If I try changing it to anything else I get this error.

Not sure where to go from here.

Interested Go On GIF by reactionseditor

Can you post your code inside a codeblock for us to review? At least the portion you renamed?

Of course! No secrets here and its not that big anyways.

// **************************************************
// Custom code for IP_DA-IndentedBOM
// Created: 1/17/2023 2:11:16 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	DynamicQueryAdapter dynamicQueryAdapter;
	EpiTextBox myPartSearchTextBoxIsSoFancy = null;
	public void InitializeCustomCode()
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls
		this.PartSearch.Click += new System.EventHandler(this.PartSearch_Click);
		myPartSearchTextBoxIsSoFancy = (EpiTextBox)csm.GetNativeControlReference("a49758c5-2a32-4706-a5e2-ab47c27805f4");
		this.GoButton.Click += new System.EventHandler(this.GoButton_Click); 
		// End Wizard Added Custom Method Calls
		dynamicQueryAdapter = new DynamicQueryAdapter(IP_DA-IndentedBOM);

	public void DestroyCustomCode()
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal
		this.GoButton.Click -= new System.EventHandler(this.GoButton_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal
		this.PartSearch.Click -= new System.EventHandler(this.PartSearch_Click);

		// End Custom Code Disposal
	private void PartSearch_Click(object sender, System.EventArgs args)
		object ret = ProcessCaller.InvokeAdapterMethod
			(oTrans.EpiBaseForm, "QuickSearchAdapter", "ShowQuickSearchForm", new object[] 
			{oTrans.EpiBaseForm, "PartSearch", false/* multi-select */, new DataTable() });
		// user cancelled
  	  if (ret == null) return; //This is a short circuit. If no value was returned, exit method.		
		myPartSearchTextBoxIsSoFancy.Text = (String)ret;
	private void GoButton_Click(object sender, System.EventArgs args)
		if(myPartSearchTextBoxIsSoFancy.Text == "")	
		MessageBox.Show("Please Enter a Part Number"); 
    private void RunBAQ()
        string myPartNum = myPartSearchTextBoxIsSoFancy.Text;
		QueryExecutionDataSet queryExecutionDataSet = new QueryExecutionDataSet();
        queryExecutionDataSet.Tables["ExecutionParameter"].Rows.Add("PartNum", myPartNum, "nvarchar", false, null, "A");
        dynamicQueryAdapter.ExecuteByID("DA-IndentedBOMBAQ", queryExecutionDataSet);
    	epiUltraGridC1.DataSource = dynamicQueryAdapter.QueryResults.Tables["Results"];

Looks like:

dynamicQueryAdapter = new DynamicQueryAdapter(IP_DA-IndentedBOM);

should be:

dynamicQueryAdapter = new DynamicQueryAdapter("IP_DA-IndentedBOM");

It needs quotes.

I believe I tried this, and it threw the third error. And it didn’t need quotes before either, so not sure why it matters now

That’s line 44 … so it’s thinking you’re subtracting two variables: IP_DA and IndentedBOM:

Sigh … I’m sorry …

Change it to this:

dynamicQueryAdapter = new DynamicQueryAdapter(oTrans);

That was it! Thanks!