08-03-2009 01:15 AM
hi all,
i found out that i need to declare act framework to getfielddescriptors. but it always need user log on, password and pad file.
do anyone have idea how to declare it globally ?
thanks,
jeff.
08-03-2009 07:05 AM
If you are working within the application then your should already have a reference to the act application. In all the samples in the sdk it is referenced as ActApp. Once you have a ref to the act application you can access the currently logged on framework by using the actframework property. If you are outsdie of the application you will always have to log on seperately.
Eg.
ActApp.ActFramework.Contacts.GetContactFieldDescriptors()
Tom
08-03-2009 07:55 AM
Hi Tdavis,
Actually this is my problem.
i need to declare ContactList cList;
and because of this i need to log on to ACT and this is under different method.
08-03-2009 07:58 AM
Are you using an application ouside of ACT! then? If so why not just collect the logon info at the start of your app, log on and then hold the actframework in a global variable to be accessed from the rest of your application.
Tom
08-03-2009 08:04 AM
Hi Tdavis,
I`m developed plugins - dll files using c#. Then i will create new tab and inside the tab got datagridview.
So may i know how to get current pad, login user name and password ?
i hope you understanding my problems and help me as my custom menu prompt user to keyed-in pad file, username and password.
but this new tab exist at contact layout and before user select my custom menu.
thanks,
Jeff.
08-03-2009 08:27 AM
So you are inside the act application then? in which case you will have a reference to the act application so just use the actframework property as in my first post.
Tom
08-03-2009 08:41 AM
HI Tdavis,
i`m had changed my code as belows. But i`m encountered errors. Error 12 Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?) .
Do you know what i had missing ?
Contact cContact = this.actApplication.ApplicationState.CurrentContact;
string ID = cContact.ID.ToString();
string fName = string.Empty;
string Customer_id = string.Empty;
string oValue = string.Empty ;
DBFieldDescriptor[] fRay = this.actApplication.ActFramework.Contacts.GetFieldDescriptors();
foreach (DBFieldDescriptor fd in fRay)
{
if (fd.DisplayName == "Cust_id")
{
fName = fd.Name;
}
}
ContactFieldDescriptor cField = this.actApplication.ActFramework.Contacts.GetContactFieldDescriptor(fName) ;
oValue = cField.GetValue(cContact);
try
{
Customer_id = oValue.ToString();
}
catch
{
Customer_id = "";
}
08-03-2009 08:50 AM
What is your field type defined as. I tend to use the code below, either should work but its worth a try...
instead of this
oValue = cField.GetValue(cContact);
try this:
oVale = cstr(cContact.Fields(fName,true))
Tom
08-03-2009 08:58 AM
Hi Tdavis,
May i know what is cSTR use for ?
As i cant find this function and it return this error.
oValue = cContact.Fields(fName, true);
Error 12 Non-invocable member 'Act.Framework.MutableEntities.MutableEntity.Fields' cannot be used like a method.
Thanks,
Jeff.
08-04-2009 02:02 AM
Hi Jeff,
That converts the value to string, I normally use vb .net though. Try the code below, I've changed the bits in bold
Contact cContact = this.actApplication.ApplicationState.CurrentContact;
string fName = string.Empty;
string Customer_id = string.Empty;
string oValue = string.Empty ;
Act.Framework.Contacts.ContactFieldDescriptor[] fRay = this.actApplication.ActFramework.Contacts.GetContactFieldDescriptors();
foreach (Act.Framework.Contacts.ContactFieldDescriptor fd in fRay)
{
if (fd.DisplayName == "Cust_id")
{
oValue = cContact.Fields(fName,True);
}
}
try
{
Customer_id = oValue;
}
catch
{
Customer_id = "";
}
Tom