URL from button based on value of field

I know there are topics similar and I am not a coder but still learning.
I am trying to setup a button in AR Invoice Entry that opens a URL based on a UD field value.
I’ve added the UD field to the customer table and added a custom data view on the form but i’m unsure how to call the field from the data view.

// **************************************************
// Custom code for ARInvoiceForm
// Created: 2/12/2021 1:11:07 PM
// **************************************************

extern alias Erp_Contracts_BO_ARInvoice;
extern alias Erp_Contracts_BO_ARPromissoryNotes;
extern alias Erp_Contracts_BO_ARInvSearch;
extern alias Erp_Contracts_BO_ARInvcDtlSearch;
extern alias Erp_Contracts_BO_Company;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Adapters_Customer;

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;

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

		this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
		// 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

		this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void epiButtonC1_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **		
		Process.Start("https://" + "CustPortal_c");		
		
	}
}

Lesson 1: Rename your button to something other than epiButton1 (you’ll regret it later if you dont

To get a hold of a customer value you can use an EpiDataView

var myDv = oTrans.Factory("Customer");//Assuming Customer is the name of your Customer DataView
string url=(string) myDv.dataView[myDv.Row]["CustPortal_c"];
Process.Start("https://" + url);
1 Like

That’s awesome, thank you Jose! It is indeed called Customer.
I knew i was missing something simple. This is super helpful and something I can use in other cases.

1 Like