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?
LVL 1
rwheeler23Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve EndowMicrosoft MVP - Dynamics GPCommented:
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



0
rwheeler23Author Commented:
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

0
Steve EndowMicrosoft MVP - Dynamics GPCommented:
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



0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

rwheeler23Author Commented:
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
0
Steve EndowMicrosoft MVP - Dynamics GPCommented:
Hi,

For VS Tools lookups, I have developed a single class that I use to lookup just about any list from GP.  It also has real-time searching within the results, automatically filtering the result set as the user types in the search box.

I used a List View, since I'm more familiar with it, but you could probably use a data grid as well.

If this is of interest, e-mail me and we can discuss directly.

Thanks,

Steve Endow
Dynamics GP Certified Trainer
Dynamics GP Certified Professional




NETSearch.jpg
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwheeler23Author Commented:
This guy knows his stuff!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.