Community
Showing results for 
Search instead for 
Do you mean 
Reply

Current Contact

Avid Listener
Posts: 30
Country: india

Current Contact

Hi,

I have this code for read the current contact from ACT :but it is in vb can u convert in C#---It is very urgent.Please help me...........

 

 

 

 

Private Sub GetCurrentContactField()
'create a contact object
Dim contact As Act.Framework.Contacts.Contact

'get the current contact
contact = ActApp.ApplicationState.CurrentContact

'get the address 1 field value
Dim Add1 As String = contact.Fields("Contact.Address 1", False)

'display the value
MsgBox(Add1)
End Sub
Thanks........
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Current Contact

snsindore,

 

first part is mthod signature

next line instantiating a Contact object

third line assigning the defined object from lin2

4th line instantiating a new string object and assigning it the value of of the contact field "Contact. Address 1" which is a non system field (i.e.false)

5th line - System.Windows.Forms.MessageBox.Show(string);

 

not much more to it really. Remeber them semi colons.

 

Or you could try and apply the filters to the Sample Code and select C# Smiley Wink 

 

Vivek

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Avid Listener
Posts: 30
Country: india

Re: Current Contact

Hi,

When we compile this code so it will give error(4th line instantiating a new string object and assigning it the value of of the contact field "Contact. Address 1" which is a non system field (i.e.false)) that here Fields is a property can't use as a method.Vivek can u give me your ph no.. 

 

 

Thanks

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Current Contact

 

Here are two web pages that I find invaluable for converting vb to c# and c# to VB:

 

http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

http://labs.developerfusion.co.uk/convert/csharp-to-vb.aspx

 

-- jim durkin

Avid Listener
Posts: 30
Country: india

Re: Current Contact

 thanks for this .code is working.CAN U TELL ME HOW CAN Make a drop down just like --Business_City (ACT).I want this type of drop down in our c#.net dialog.For making a dll.

 

 

Thanks

Pawan  

Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Current Contact

Hi Pawan,

 

I just haven't been able to work this one out. Hopefully someone might be able to shed some further light on where I am going wrong in my code, otherwise my conclusion has been that its just not possible since I can not work out how to write to the FieldDescriptor.FieldDescriptorCollection object and Add() a new Attribute to it...

 

ActFramework oFram = new ActFramework(); 

oFram.LogOn(@"C:\Users\xxx\Documents\ACT\ACT for Windows 10\Databases\ACT10Demo.PAD", "Chris huffman", "");

oFram.PickLists.CreatePickList(Act.Framework.PickLists.PickListType.Character, "User 1"); //Create new Picklist unpopulated

Act.Framework.PickLists.PickList pList = oFram.PickLists.GetPickList("User 1"); //Gets our Picklist we just made

 

FieldDescriptorCollection fields = oFram.Fields.GetFields(RecordType.Contact); //Gets all the Contact Fields

FieldDescriptor fD = fields.Find("User 1"); //Gets the User 1 Field. We want to assign our PickList to this Field:

 

FieldDescriptor.FieldDescriptorAttributeCollection attribs = fD.Attributes;

PickListAttribute plAttrib = new PickListAttribute(pList, false, true, true, true);

//can not set the attribute since attribs is readonly!

 

oFram.LogOff();

 

I hope I am doing something really stupid and thre is a way, I have a batch utility that could do with this working!

If not, Feature Request can we make the FieldDescriptor.FieldDescriptorAttributeCollection (get, set) Have a Public method?

 

Vivek

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Copper Contributor
Posts: 87
Country: USA

Re: Current Contact

Not sure what is being requested.  Do you want to create a Drop Down List?  Do you want to add items to a Drop Down List?  Or do you want to associate a file with a Drop Down List?  I do all of these in my Batch Field Creator Pro product, and would be happy to hwlop (it's in VB, not C#), but I don't know what you're trying to do.  And perhaps you should start a new thread with the correct subject, so that others can pitch in?

Geoff

Geoff Blood ("The ACT! Customizer" )
The New Hampton Group

ACT Development Partner
Serving the ACC community since 1994
Nickel Super Contributor
Posts: 441
Country: UK

Re: Current Contact

Try This

 

 

field.Attributes(Act.Framework.Database.FieldProperty.PickList) = New Act.Framework.Database.PickListAttribute(ActApp.ActFramework.PickLists.GetPickList(Picklist), True, False, True, False)

 

 Tom
Bronze Elite Contributor
Posts: 2,115
Country: United_Kingdom

Re: Current Contact

Hi Tom,

 

Your a star! Thanks for that, it seems so bloody obvious now! HahahaSmiley Very Happy

 

Vivek

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Tuned Listener
Posts: 4
Country: United States

Re: Current Contact

hi,

 

I get error on line _actApplication.ApplicationState.CurrentContact

 

_actApplication is null. How do I get instance of _actApplication.

 

Please help.

 

Thanks,

Saifee.A