4 Replies Latest reply on Mar 26, 2018 2:06 AM by piotr.zambrzycki

    update contact

    Apprentice

      Hi All,

       

      I am working on goldmine integration in C# program and I am running into issues.

      I have this code and it is throwing an error, I don't know what I am doing wrong.

       

        public static string updateContact(Contact contact)

              {

                  IntPtr lC1WA;

                  IntPtr lC2WA;

                  IntPtr lCSWA;

                  IntPtr lRes;

                  IntPtr lresult;

       

       

                  lC1WA = GMW_DB_Open("Contact1");

                  lC2WA = GMW_DB_Open("Contact2");

                  lCSWA = GMW_DB_Open("ContSupp");

       

                  //If all files are opened OK...

                  if (lC1WA != IntPtr.Zero && lC2WA != IntPtr.Zero && lCSWA != IntPtr.Zero)

                  {            

                      IntPtr nvc = GMW_DB_Seek(lC1WA, contact.lastName.ToUpper());

                      //Perform the seek

                      if (nvc != IntPtr.Zero)

                      {                 

                          GMW_DB_Replace(lC1WA, "Company", "zzzzzzz", (IntPtr)20);                 

                          lresult = GMW_Execute("UFreContact", lC1WA);

                      }

                  }

                  else

                  {

                      return "1";

                  }           

                  return "0";

              }

       

      Thank you for your help

        • 1. Re: update contact
          SupportEmployee

          Hi Hind,

           

          Can you tell me what is the exact error message that you are getting?

          • 2. Re: update contact
            Apprentice

            Hi Piotr,

             

            Thank you for your prompt response.

            I was able to update contact via GMW_DB_QuickReplace command. I am running into a lot of issues:

             

            FYI: I am using Gm7s32.dll library, I could not find sample codes when integrating goldmine using .Net and C#.

             

            Now I am having other issue:

            I am trying to create contact. Primary information is successfully stored in the contact1 information table, but I don’t know how to store additional information it in the contact2 table, also health information do not get stored.

             

                  public static string createContact(Contact contact)

                    {

                        IntPtr nvc = GMW_NV_Create();

                        IntPtr lresult1;

             

                        GMW_NV_SetValue(nvc, "ACCOUNTNO", contact.customerNumber);

                        GMW_NV_SetValue(nvc, "Key5", contact.customerNumber);

                        GMW_NV_SetValue(nvc, "Company", contact.company);

                        GMW_NV_SetValue(nvc, "Dear", contact.salutation);

                        GMW_NV_SetValue(nvc, "Lastname", contact.lastName);

                        GMW_NV_SetValue(nvc, "Contact", contact.firstName);

                        GMW_NV_SetValue(nvc, "Address1", contact.address1);

                        GMW_NV_SetValue(nvc, "Address2", contact.address2);

                        GMW_NV_SetValue(nvc, "Address3", contact.address3);

                        GMW_NV_SetValue(nvc, "City", contact.city);

                        GMW_NV_SetValue(nvc, "State", contact.state);

                        GMW_NV_SetValue(nvc, "Zip", contact.zip);

                        GMW_NV_SetValue(nvc, "Country", contact.country);

                        GMW_NV_SetValue(nvc, "Phone1", contact.phone);

                        GMW_NV_SetValue(nvc, "Company", contact.company);           

                        GMW_NV_SetValue(nvc, "Fax", contact.fax);

                        GMW_NV_SetValue(nvc, "Key2", contact.health.healthCard);

                        GMW_NV_SetValue(nvc, "Key4", contact.health.claimNum);

                        lresult1 = GMW_Execute("WriteContact", nvc);        

                    }

             

                 This is my code for inserting/updating contact in contact2 but I don't know how to make it working

                 public static string createContact2(Contact contact)

                    {

                        IntPtr lC1WA;         

                        IntPtr lRes;

             

                        StringBuilder sRectID = new StringBuilder();          

                        lC1WA = GMW_DB_Open("Contact1");          

             

                        StringBuilder sAccNo = new StringBuilder();

                       

                        if (lC1WA != IntPtr.Zero)

                        {

                            //Set the index order

                            lRes = GMW_DB_SetOrder(lC1WA, "ContName");

             

                            //Perform the seek

                            if (GMW_DB_Seek(lC1WA, "75493") == 1)

                            {

                                lRes = GMW_DB_Read(lC1WA, "RecID", sRectID, (IntPtr)21);

                                lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "Company", "test", 0);

                                lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "Phone1", "9999999999", 0);

                                lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "Address1", "test", 0);

                                lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "City", "Toronto", 0);

                            }else

                            {

             

                            }

                        }

             

            Thank you,

            Hind

             

            • 3. Re: update contact
              Apprentice

              Also,

              I am trying to save contact information to ContSupp table using Gm7s32.dll and C#. do you have a sample code please?

               

              Thank you

              • 4. Re: update contact
                SupportEmployee

                Hi Hind,

                 

                I do have 2 questions regarding the code.

                 

                First one is:

                - Are you running both of those codes at once?

                 

                //

                public static string createContact(Contact contact)

                        {

                            IntPtr nvc = GMW_NV_Create();

                            IntPtr lresult1;

                 

                            GMW_NV_SetValue(nvc, "ACCOUNTNO", contact.customerNumber);

                            GMW_NV_SetValue(nvc, "Key5", contact.customerNumber);

                            GMW_NV_SetValue(nvc, "Company", contact.company);

                            GMW_NV_SetValue(nvc, "Dear", contact.salutation);

                            GMW_NV_SetValue(nvc, "Lastname", contact.lastName);

                            GMW_NV_SetValue(nvc, "Contact", contact.firstName);

                            GMW_NV_SetValue(nvc, "Address1", contact.address1);

                            GMW_NV_SetValue(nvc, "Address2", contact.address2);

                            GMW_NV_SetValue(nvc, "Address3", contact.address3);

                            GMW_NV_SetValue(nvc, "City", contact.city);

                            GMW_NV_SetValue(nvc, "State", contact.state);

                            GMW_NV_SetValue(nvc, "Zip", contact.zip);

                            GMW_NV_SetValue(nvc, "Country", contact.country);

                            GMW_NV_SetValue(nvc, "Phone1", contact.phone);

                            GMW_NV_SetValue(nvc, "Company", contact.company);           

                            GMW_NV_SetValue(nvc, "Fax", contact.fax);

                            GMW_NV_SetValue(nvc, "Key2", contact.health.healthCard);

                            GMW_NV_SetValue(nvc, "Key4", contact.health.claimNum);

                            lresult1 = GMW_Execute("WriteContact", nvc);        

                        }

                   {

                            IntPtr lC1WA;         

                            IntPtr lRes;

                 

                            StringBuilder sRectID = new StringBuilder();          

                            lC1WA = GMW_DB_Open("Contact1");          

                 

                            StringBuilder sAccNo = new StringBuilder();

                           

                            if (lC1WA != IntPtr.Zero)

                            {

                                //Set the index order

                                lRes = GMW_DB_SetOrder(lC1WA, "ContName");

                 

                                //Perform the seek

                                if (GMW_DB_Seek(lC1WA, "75493") == 1)

                                {

                                    lRes = GMW_DB_Read(lC1WA, "RecID", sRectID, (IntPtr)21);

                                    lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "Company", "test", 0);

                                    lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "Phone1", "9999999999", 0);

                                    lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "Address1", "test", 0);

                                    lRes = GMW_DB_QuickReplace("Contact1", sRectID.ToString(), "City", "Toronto", 0);

                                }else

                                {

                 

                                }

                            }

                //

                 

                - Still you have not provided the error message. Can past the whole code from C# and the error message?

                 

                (this part I am not so sure but will check in a spare moment)

                One last thing is that it looks like you are creating contact instead of contact1

                public static string createContact(Contact contact)

                instead of

                public static string createContact1(Contact contact)

                 

                Thank you in advance,

                 

                Kindest regards,