Community
Showing results for 
Search instead for 
Do you mean 
Reply

How to Get Address ID from ACT

New Member
Posts: 7
Country: India

How to Get Address ID from ACT

I am writing  code to read address details from ACT. I have  retrived all Address details from ACT! Address but not gettting how to read ADDRESSID from ACT. 

Nickel Contributor
Posts: 175
Country: USA

Re: How to Get Address ID from ACT

I'm not familiar with the Address object, but most ACT data objects (Contact, Company, Opportunity) have an ID property that gets the proper ID (i.e. contact.ID gets the ContactID field). If you are using the Act.Framework.Database.AddressTemplate object, it also has an ID property. Hope that helps.
New Member
Posts: 7
Country: India

Re: How to Get Address ID from ACT

[ Edited ]

Thanks for your response. I have tried this but it is passing random AddressID instead of actual AddressID from Address table.

 

Please find my below code. I am trying to do something like that. For now I am passing null value in  @Addr_ID and @src_addressid where I want to pass actual AddressID from Address.

 

private void GetCompanyBuisnessAddress(Company objCompany , CompanyFieldDescriptor[] objCompFields)
        {
            //Act.Framework.Database.AddressTemplate test = new AddressTemplate("ID",RecordType.Company);
            try
            {
                bool isValidAddress = false;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_LINE1").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_LINE2").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_LINE3").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_STATE").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_CITY").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_POSTALCODE").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;

                if (objActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.BUSINESS_COUNTRYNAME").GetValue(objCompany) != null && isValidAddress == false)
                    isValidAddress = true;
  
                if (isValidAddress)
                {
                    //SP To insert data into Company's Address
                    SqlHelper.ExecuteNonQuery(connstring, System.Data.CommandType.StoredProcedure, "INSERT_ADDRESS",
                       new SqlParameter("@Src_CompanyID", objCompany.ID.ToString()),
                       new SqlParameter("@Src_CreatorID", Convert.ToString(objCompany.Fields["CREATEUSERID", Act.Framework.MutableEntities.FieldNameType.Alias])),
                       new SqlParameter("@Addr_Address1", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_LINE1", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_Address2", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_LINE2", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_Address3", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_LINE3", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_City", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_CITY", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_State", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_STATE", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_County", DBNull.Value),
                       new SqlParameter("@Addr_PostCode", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_POSTALCODE", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_Country", Convert.ToString(objCompany.Fields["TBL_COMPANY.BUSINESS_COUNTRYNAME", Act.Framework.MutableEntities.FieldNameType.Real])),
                       new SqlParameter("@Addr_ID", DBNull.Value),
                       new SqlParameter("@src_addressid", DBNull.Value),
                       );

                    //Console.WriteLine(test.ID.ToString());
                }
            }
            catch (NullReferenceException nullEXP)
            {
                throw new Exception(nullEXP.Message);
            }
            catch (Exception exp)
            {
                throw new Exception(exp.Message);
            }
        }

 

 

Nickel Contributor
Posts: 175
Country: USA

Re: How to Get Address ID from ACT

From the looks of it, you are inserting data into some table. In this scenario, you need to have the AddressID in order to insert it, but based on the code you posted, you don't have it. I presume you are trying to insert into a non-ACT table since it appears that you are using direct SQL commands or stored procedures, and not the ACT API. Outside of that, I don't know what you are really trying to do. Could you please post an overview of what you are trying to accomplish? That could help to find where your issue lies. Thanks.
New Member
Posts: 7
Country: India

Re: How to Get Address ID from ACT

Yes you are correct, I am trying to fetch data from ACT! and inserting it into seperate SQL Database Table. This is just one function where I have passed object of the Company and fetching its Addresses from ACT Address . I also wants to include AddressID into that for future referance. But not getting how to get AddressID related to that Company. Hope you have understood what I am trying achive. 

Nickel Contributor
Posts: 175
Country: USA

Re: How to Get Address ID from ACT

I dug through the ACT API a bit more (in object browser in visual studio) and I saw no way to get at the address ID. What I mentioned before with the AddressTemplate doesn't look like it would help, it appears to be more of a schema than actual data. There was an enumeration that I found that seemed promising, but I couldn't find any method that used it. It is Act.Framework.Companies.StandardTable.

As I see it, the most sure way at this point to get the Address ID would be to use OLEDB2 to query against the table directly (if that table is even available). Since you have the company you are looking for, you could filter by the company id. I haven't used this method to get data, but I do know there are a number of threads that walk through the process on this forum. Sorry I couldn't be of more help.
New Member
Posts: 7
Country: India

Re: How to Get Address ID from ACT

Ok..Thanks for your time. Smiley Happy  I will look into it.