08-24-2012 03:11 PM
Hi. I just started working with the SDK. I am finally able to call the ACT framework and sucessfully log in to my database.
Now I need to come up with a way to have a form where a field value for Company (let's say "Name") can be entered, the data looked up and the results displayed on a .aspx page.
I was able to do something similar for contacts but nothing, so far, for companies.
For now, I would be happy just to be able to get a list of all Companies and display that as a data grid on my .aspx page.
I have looked around as much as I could in the forums for help with this before posting. I can't seem to find anything relevant to working with Companies.
Has anyone had success doing something like this? Any code samples would be greatly appreciated.
08-27-2012 07:17 AM
Doing this for contacts or companies ought to be nearly identical in so far as just getting a list of companies based on a name or some other criteria. The code to get a list of comanies filtered by name would look something like this:
String companyName = "myCompanyName";
CompanyFieldDescriptor fd = ActApp.ActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.NAME", Act.Framework.MutableEntities.FieldNameType.Real);
ComparisonFilterCriteria comparisonFilter = new ComparisonFilterCriteria(fd, ComparisonFilterCriteria.Operation.Equals, companyName);
ComparisonFilterCriteria filters = new ComparisonFilterCriteria;
filters = comparisonFilter;
CompanyList cl = ActApp.ActFramework.Companies.GetCompanies(null, filters);
From there you should have a list of companies that can be displayed on your datagrid. You can also choose to either display the form yourself using standard .Net stuff, or you can use our LoadSDIView method which takes a a form as it's only parameter and displays the form within Act.
08-27-2012 12:46 PM
Hi. Thanks for the response. That got me pointed in the right direction. What I would like to do now is use a SQL query to return data so that I can multiple criteria to search on. I know that for Contacts, I would do this like so:
string ssql = "SELECT * FROM TBL_CONTACT WHERE column1 = '" + myFormField.text + "' AND column2 = 1";
ContactLookup ACTLookup = ACTFM.Lookups.LookupContactsReplace(ssql, true, true);
ContactList ACTList = ACTLookup.GetContacts(null);
What would be the equivalent code for doing a look up for Companies? Is there a reference that has the various methods, functions, etc. that can be used for the ACT framework? I haven't been able to find much in the SDK examples for working with data for Companies.
Thanks again for the help.
08-27-2012 01:04 PM
The exact same method exists for companies (LookupCopmaniesReplace) and yes there is a code reference. Within the SDK download, browse to the following location: \\Sage ACT! 2012 SDK\Content\Code Reference, in there is a searchable .cfm help file.
08-30-2012 02:30 PM
Hi. Thank you for your help. I think that I am close to getting this to work. In trying to convert my Contact lookup to a Company look up, I now have the following code:
string ssql = "SELECT * FROM TBL_COMPANY WHERE NAME = '" + txtProUserId.Text + "'";
CompanyLookup ACTLookup = ACTFM.Lookups.LookupCompaniesReplace(ssql,true,true);
CompanyList ACTList = ACTLookup.Companies(null);
I'm getting the following error on the second line (in bold) above:
CS1502: The best overloaded method match for 'Act.Framework.Lookups.LookupManager.LookupCompaniesReplace(object, Act.Framework.Lookups.OperatorEnum, Act.Framework.MutableEntities.MutableEntityFieldDescriptor)' has some invalid arguments
I can't figure out what I'm doing wrong. Should I be passing something different to LookupCompaniesReplace()?
Thanks again for the help. I appreciate it. I think I'm almost there for doing a lookup on a company name and displaying the results.
08-31-2012 11:19 AM
That method doesn't accept a SQL statement as one of its parameters. I think the best overload choice would be:
public CompanyLookup LookupCompaniesReplace( object val, OperatorEnum op, CriteriaColumn column, bool includePrivate )
Where val would be the name of the company you want to search for, op would be equals, column the Company Name column and the last depends on your needs.
string val = "Test"; CompanyFieldDescriptor compField = _ActApp.ActFramework.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.NAME", true); _ActApp.ActFramework.Lookups.LookupCompaniesReplace(val, OperatorEnum.Contains, compField);
08-31-2012 12:11 PM
Thank you so much for your help. I think I now understand now how to do a search using LookupCompaniesReplace(val, operatorEnum, column). What I'm still stuck on is how to return the data. I am getting an error when I try to bind the data returned. I am simply trying to display the first Company Name returned:
string val = myFormField.Text;
CompanyFieldDescriptor compField = ACTFM.Companies.GetCompanyFieldDescriptor("TBL_COMPANY.NAME", true);
CompanyLookup ACTLookup = ACTFM.Lookups.LookupCompaniesReplace(val, OperatorEnum.Contains, compField);
CompanyList ACTList = ACTLookup.GetCompanies(null);
if (ACTList.Count > 0)
lblIsUser.Text = ACTList.NAME;
I am getting an error on the line above in bold.This is the error that I am getting:
CS1061: 'Act.Framework.Companies.Company' does not contain a definition for 'NAME' and no extension method 'NAME' accepting a first argument of type 'Act.Framework.Companies.Company' could be found (are you missing a using directive or an assembly reference?)
What would the correct syntax be for returning a field value from the lookup?