Link to home
Start Free TrialLog in
Avatar of rwheeler23
rwheeler23Flag for United States of America

asked on

MS Dynamics GP 10 Visual Studio read only

I needed to add a lookup to an external table to the Project Accounting Billing Entry screen. What I present to the user is a job number and an agency code. The agency code is the GP customer number. When I inserted the line to update the CustomerNumber field on the billing entry screen I get a build error stating the property of this field is read-only. Using VS Tools for GP 10 is there anyway to update a GP variable?
Avatar of Steve Endow
Steve Endow
Flag of United States of America image

Hi,

Are you trying to populate empty fields on a new, blank Billing Entry invoice, or are you trying to update the Customer ID for an existing invoice?

In theory, it looks like you should be able to populate an empty Customer ID, but non-core products like PA can be pretty inconsistent or flaky with VS Tools, and I haven't done any automation with that window, so I can't say for sure without testing it.

If you want to post your relevant code, I can give it a try.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional



Avatar of rwheeler23

ASKER

Notice the commented code down after the datagridview. This is the section that will not build because it says the field is read-only. This lookup window would be used for a new Billing Entry prior to selecting the customer ID. Please remember to add the Application.ProjectAccounting.dll if you try to build this.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using Microsoft.Dexterity.Applications.DynamicsDictionary;
using Microsoft.Dexterity.Applications.ProjectAccountingDictionary;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Microsoft.Dexterity.Bridge;
using Microsoft.Dexterity.Applications;
using Microsoft.Dexterity.Shell;

namespace ViewAgenciesByJob
{
    public partial class ViewAgenciesByJobs : DexUIForm
    {
        // Create a reference to the Project Billing Entry Window
        static PaBillingEntryForm PaBillingEntryForm = ProjectAccounting.Forms.PaBillingEntry;
        static PaBillingEntryForm.PaBillingEntryWindow PaBillingEntryWindow = PaBillingEntryForm.PaBillingEntry;

        /* Setup PA Billing Entry form so you send back value for Customer ID */
        private System.Data.SqlClient.SqlConnection jobconnection;
        private System.Data.DataSet AgenciesByJobsDataSet;
        private System.Data.SqlClient.SqlCommand AgenciesByJobsCommand;
        private System.Data.SqlClient.SqlDataAdapter DataAdapter;

        /* Define connection string */
        string connectionString = "";
        string CustomerNumber = "";

        public ViewAgenciesByJobs(string cs)
        {
            connectionString = cs;

            InitializeComponent();

            try
            {
                /* Define the data set for Agencies by Jobs */
                jobconnection = new System.Data.SqlClient.SqlConnection(connectionString);

                /* Open the connection */
                jobconnection.Open();

                AgenciesByJobsDataSet = new System.Data.DataSet();
                AgenciesByJobsDataSet.CaseSensitive = false;

                AgenciesByJobsCommand = new System.Data.SqlClient.SqlCommand();
                AgenciesByJobsCommand.Connection = jobconnection;

                AgenciesByJobsCommand.CommandText = "SELECT JOBNUMBER,AGENCY FROM JOBS ORDER BY JOBNUMBER";

                DataAdapter = new System.Data.SqlClient.SqlDataAdapter();
                DataAdapter.SelectCommand = AgenciesByJobsCommand;
                DataAdapter.TableMappings.Add("Table", "AgenciesByJobs");
                DataAdapter.Fill(AgenciesByJobsDataSet);

                dgvAgenciesByJobs.ReadOnly = true;
                dgvAgenciesByJobs.RowHeadersVisible = false;
                               
                dgvAgenciesByJobs.DataSource = AgenciesByJobsDataSet.Tables["AgenciesByJobs"].DefaultView;
                dgvAgenciesByJobs.Columns[0].Width = 85;
                dgvAgenciesByJobs.Columns[0].HeaderText = "Job Number";
                dgvAgenciesByJobs.Columns[1].Width = 95;
                dgvAgenciesByJobs.Columns[1].HeaderText = "Agency Code";

                /* Extract customer number value from current row to pass back to Billing Entry screen 
                CustomerNumber = AgenciesByJobsDataSet.Tables["AgenciesByJobs"].Rows[0]["AGENCY"].ToString();
                PaBillingEntryWindow.CustomerNumber = CustomerNumber; */
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            /* Close the job connection */
            try
            {
                jobconnection.Close();
            }
            catch(Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Hide();
            this.Dispose();
        }


    }
}

Open in new window

Hi,

Try this:

PaBillingEntryWindow.CustomerNumber.Value = "AARONFIT0001";

You need to assign the value to the CustomerNumber property called Value.  Without ".Value", it thinks you are trying to assign an object.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional



Steve, you are correct again. Now what I am trying to do is provide a lookup box to get the customer number. I have an external database that has job numbers in them. On each job is an agency. Jobs are projects and agencies are customers.  I used a datagridview because the columns line up nicely. This is just a lookup window. I want the user to be able to select a row and have it return the agency code to the customer number field. Can that be doen using a datagridview? Is there something better? If you want to alter the code just send me an invoice for your time.
AgenciesByJobs.jpg
ASKER CERTIFIED SOLUTION
Avatar of Steve Endow
Steve Endow
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This guy knows his stuff!!!