The code works but only after the first dispatch for that requisition processes.
Here is the code from our requisition dispatch customization script editor:
// **************************************************
// Custom code for DispatchForm - Working for ReqApproval Customization - All Companies
// Created: 4/27/2020 9:36:47 PM
// **************************************************
extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Vendor;
extern alias Erp_Contracts_BO_VendorPPSearch;
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.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;
using Ice.Lib.Broadcast;
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 **
BAQDataView bAHPurReqUserBAQDV;
public void InitializeCustomCode()
{
CreateBAHPurReqUserBAQDV();
// ** 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
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
public void CreateBAHPurReqUserBAQDV()
{
bAHPurReqUserBAQDV = new BAQDataView("BAHPurReqUser");
oTrans.Add("BAHPurReqUserBAQDV", bAHPurReqUserBAQDV);
string pub1Binding = "ReqHead.ReqNum";
IPublisher pub1 = oTrans.GetPublisher(pub1Binding);
if (pub1 == null)
{
string pubName = Guid.NewGuid().ToString();
oTrans.PublishColumnChange(pub1Binding, pubName);
pub1 = oTrans.GetPublisher(pub1Binding);
}
if (pub1 != null)
bAHPurReqUserBAQDV.SubscribeToPublisher(pub1.PublishName, "ReqHead_ReqNum");
}
}