?
Solved

MS Dynamics GP 10 Visual Studio read only

Posted on 2010-03-23
6
Medium Priority
?
593 Views
Last Modified: 2013-12-17
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?
0
Comment
Question by:rwheeler23
  • 3
  • 3
6 Comments
 
LVL 18

Expert Comment

by:Steve Endow
ID: 28394785
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
 

Author Comment

by:rwheeler23
ID: 28400935
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
 
LVL 18

Expert Comment

by:Steve Endow
ID: 28402693
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:rwheeler23
ID: 28441607
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
 
LVL 18

Accepted Solution

by:
Steve Endow earned 2000 total points
ID: 28460528
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
 

Author Closing Comment

by:rwheeler23
ID: 31706350
This guy knows his stuff!!!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, I've just fixed a problem with Sage 50 Accounts 2011 crashing when creating a new Company.  I've wasted several hours on it so I thought I'd share the solution with others.  Remarkably, the same laptop had what appears to be exactly the same …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…
Suggested Courses
Course of the Month5 days, 1 hour left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question