Vendor UD field update from APInvoice entry

Hi All, I´m a little bit lost here, and looking for some guidance.

I have added a UD Field to the Vendor table (Vendor_UD), List_c is the field name.
in the Invoice entry module after creating the Group and selecting the supplier, using a custom which is already working properly, we load the invoice into the system (working fine).

Right now I have been able to perform the “search” for that specific TaxID in an existing table (UD03) and return a value if found.

Here comes my issue, after that I need, if a value is returned, to update the List_c field from the Vendor table.

did I explain my self properly? any suggestions?

This sounds like a bpm. Is that what you are doing?

Hi Ken, not really, I was expecting to perform this action only based on a customiztation code. is that possible?
I haven´t used a BPM at all, yet… so I´m not familiar with the processes.

Hi all,

so far this is the code I have regarding this, unfortunately I´m getting an Object reference not set to an instance of an object error…

public void UD03update (string _company, string _rfc,string _uuid, string _period, string _year)
{
	EpiDataView edvUD03 = GetDataView("Ice.UD03");
	edvUD03.dataView[edvUD03.Row]["Company"]=_company;
	edvUD03.dataView[edvUD03.Row]["Key1"]=_rfc;
	edvUD03.dataView[edvUD03.Row]["Character01"]=_uuid;
	edvUD03.dataView[edvUD03.Row]["Character02"]=_period;
	edvUD03.dataView[edvUD03.Row]["Character03"]=_year;
}

what I´m missing?

I have added at the beginning of the public class Script:

public class Script
{
	//CultureInfo us = new CultureInfo("en-US");
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **	

    public EpiDataView edvUD03;

I also have it Initialized:

public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
	edvUD03 = ((EpiDataView)(this.oTrans.EpiDataViews["Ice.UD03"]));

but still can´t figure it out where is it that I´m wrong… any guess or suggestions?

This is on the UD03 Form?

If so, it might be a good idea to use a BPM. Then your custom code is not really needed . You set the epiDataView to the controls and then use the epiMagic to do the getnew, update, and what not. Then you can leverage the BPM to do the look up and fill.

If I am off, please let me know your business case so we can help you better.

Hi Ken, no it is not on the UD03 form, it is on the APInvoiceEntry form…

I have a table with some “blacklisted” TaxID numbers. I have a method which basically search for the Vendor TaxID in the invoice on that “blacklist” and want everytime the search returns a positive value to record in the UD03 table the company, taxid, fiscal period, fiscal year…

Perhaps the BPM should be better, unfortunately I have no experience on that and no Idea on how to start it that way.

When is the method called? Where is the blacklisted table stored?

The blacklist is another UD table, UD05 which is updated every End of Month.

and this is the Code I use to validate against the blacklist…

public string rfcsat (string _rfcvend2)
{
	string res = "0";
	String Reg = String.Empty;
	SqlConnection Conn = new SqlConnection("Data Source = WEPICORSQL; Initial Catalog = DB ;User Id =User; Password =psw");
	SqlDataReader eRdr = null;
	try 
	{
		Conn.Open();
		SqlCommand cmd = new SqlCommand(@"select Key1 from Ice.UD05 where Character01 = '"+ _rfcvend2 + "'" , Conn);
		eRdr = cmd.ExecuteReader();
		while (eRdr.Read()){ Reg = eRdr[0].ToString(); res=Reg; }
	}
	finally
	{
		if (eRdr != null)
        	{eRdr.Close();}
        if (Conn != null)
        	{Conn.Close();}
	}
	return res;
}

and this is called on a button click event.

OK…I am slow :wink: this is what I think you are trying to do.

APInvoiceEntry form button click event. (is this custom?) or on save

Does a look up with the vendor num on the Invoice to the UD05 Blacklist table

If the vendor num is found; then add a record to the UD03 table with UD field from Vendor.

Which line is the object reference error? Your edvUD03 is blank. The code references a row which I am guessing is not on the APInvoiceEntry form.

edvUD03.dataView[edvUD03.Row]

Are you trying to create a New UD03 Row or Update a UD03 Row that already exists?

that´s correct!!!

I´m trying to crate a new UD03 Row.

Error Detail 
============
Message: Object reference not set to an instance of an object.
Program: App.APInvoiceEntry.APInvoiceForm.EP.CAD02.Customization.APInvoiceGral_v1.2.CustomCode.14.dll
Method: UD03update

does this work as a new function?

private void CreateUD03(string _company, string _rfc,string _uuid, string _period, string _year)
{
	try
	{
		UD03Impl UD03BO = WCFServiceSupport.CreateImpl<UD03Impl>(FormFunctions.getILaunchSession(oTrans), UD03Impl.UriPath);
		UD03DataSet tempSet = new UD03DataSet();
		UD03BO.GetaNewUD03(tempSet);

		tempSet.Tables[0].Rows[0]["Key1"] = _rfc;
		tempSet.Tables[0].Rows[0]["Character01"] = _uuid;
		tempSet.Tables[0].Rows[0]["Character02"] = _period;
		tempSet.Tables[0].Rows[0]["Character03"] = _year;
		
		UD03BO.Update(tempSet);
	}

	catch (Exception ex) { MessageBox.Show("Exception thrown by CreateNotification: " + ex.Message); }
}

Am I missing References? which one I´m missing?

 Error: CS0246 - line 2200 (5702) - The type or namespace name 'UD03Impl' could not be found (are you missing a using directive or an assembly reference?)
 Error: CS0103 - line 2200 (5702) - The name 'UD03Impl' does not exist in the current context
 Error: CS0246 - line 2201 (5703) - The type or namespace name 'UD03DataSet' could not be found (are you missing a using directive or an assembly reference?)

Capture

#region Using statements

using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Ice.Adapters;
using Ice.BO;
using Ice.Contracts;
using Ice.Lib.Framework;
using Ice.Lib.HelpExceptionProvider;
using Ice.Proxy.BO;
using Ice.Tablesets;
using Infragistics.Win;
using Infragistics.Win.Misc;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinToolbars;
using System.IO;
using Infragistics.Win.UltraWinDock;

I´ve addedd all the references and all the “usings” and still getting the following error.

 Error: CS0246 - line 2213 (5718) - The type or namespace name 'UD03Impl' could not be found (are you missing a using directive or an assembly reference?)

 Error: CS0103 - line 2213 (5718) - The name 'UD03Impl' does not exist in the current context

I have initialized the UD03Impl but now getting the following errors…

 Error: CS0118 - line 2214 (5719) - 'Script.UD03Impl' is a 'field' but is used like a 'type'
 Error: CS0118 - line 2214 (5719) - 'Script.UD03Impl' is a 'field' but is used like a 'type'
 Error: CS1061 - line 2214 (5719) - 'Ice.Adapters.UD03Adapter' does not contain a definition for 'UriPath' and no extension method 'UriPath' accepting a first argument of type 'Ice.Adapters.UD03Adapter' could be found (are you missing a using directive or an assembly reference?)

I´m getting crazy with this…

Here is a test that worked.

References

// **************************************************
// Custom code for UD01Form
// Created: 5/30/2018 7:17:13 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
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;

 using Ice.Proxy.BO;


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 **

	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

		// 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
	}

	private void msTestSub()
	{
		
		UD03Impl UD03BO = WCFServiceSupport.CreateImpl<Ice.Proxy.BO.UD03Impl>(FormFunctions.getILaunchSession(oTrans), UD03Impl.UriPath);
		
		UD03DataSet tempSet = new UD03DataSet();

		UD03BO.GetaNewUD03(tempSet);

		tempSet.Tables[0].Rows[0]["Key1"] = "key1";
		
		UD03BO.Update(tempSet);

	}
}
1 Like

Dam… you nailed Ken… it is now compiling properly… i was missing those 2 references…

Thank you very much!!!