04-17-2008 09:31 AM
Newbie alert! Im running ACT!10 and developing (or trying to!) some plugins with VB .NET. I was wondering if there is a unique ID field for the Contacts in ACT? I know there is a unique guid, however Im after a number, that maybe increments by 1 each time a record is created?
I want to provide a ticket number essentially for each contact record - and a guid isnt exactly friendly for people to tell customers over the phone! Maybe there is something built in already?
Apologies if this is a stupid question, I have had a good look on the forum and within the SDK but couldnt find anything...
04-17-2008 09:38 AM
Sorry, forgot to add. I already have a plugin that looks at a custom field I have created, iterates through them all, then increments the highest number by 1, and updates the current record. That would be ok, except when people say delete a contact, a duplicate number could be provided. Just thought Id pass that on...
Furthermore, any idea how a user could run a plugin that operates on elavated user rights, rather than their own access rights? For eg, updating a read only field that only certain people have rights to?
04-17-2008 02:57 PM
If you already have a plugin that has itterated through the contaclist collection you could add one final line to to the end after the last itteration that outputs the value to an XML file e.g:
int count = contactList.count;
foreach(Act.Framework.Contacts.Contact cont in contactList)
XmlDocument doc = new XmlDocument();
So now you have gotten your "markpoint" i.e. you will start counting from this number onwards you can just run your second plugin that just reads the xml file in and increments value by 1.
XmlTextReader reader = new XmlTextReader(@"D:\settings.xml");
The code is in C# but hopefully you can see what I am trying to do, I'm not very good with VB anymore and forgotten most of VB syntax!
04-17-2008 03:20 PM
Thanks for the reply! I haven't really used XML files in my applications before, and don't know the advantages/disadvantages behind them, so might need another heads up, but...if Im assuming that you write to the XML every time a new number is needed, you wouldn't need to iterate through the contact list collection, just read the XML and increment by 1? And do away with the ACT db iteration entirely? If so, is this method better than say storing the values in a SQL database and incrementing?
Like I say I haven't used XML files at all, and not sure how a file would compare/compete against a SQL db for eg?
One last thing which emphasises my position as ACT chief newbie...I guess all plugins can be stored in the plugin directory on the ACT server, and these plugins will be available to all, rather than copying DLLs (plugins) to each individual PC that is running ACT?
Anyhow, I like your thoughts and will give it go!
Thanks a milion
04-18-2008 01:53 AM
Sorry about not being clear you caught me out being a bit lazy! Basically what I was thinking was that you have a custom field in the dB called something like 'Ticket No'. You would find the total count of contacts in the contactList of All contacts this only needs to be done once as you correctly pointed out. Since we only need to keep a record of this number it is easier to possibly save the value to a settings file. In the old VB6 days you might have kept this value in the registry or an ini file but since .NET works well with xml and the code is fairly simple you might as well save the value to a xml file so that when you next need to allocate a ticket no the plugin just checks the value and just allocates a new number count++ and updates the field as well as the xml file. You may need to check for concurrancy issues and file loacks if someone has a lock on the xml whilst they are updating it etc.
With regards to Plugin locations, you will need to install the plugin on each machine locally.
04-18-2008 03:02 AM
No, your explanation was good thanks, and laziness is my forte
A couple of issues though. Why would I need to query ACT for the total count of contacts at all if all I am doing is incrementing the value in the xml file? From my understanding, it only needs to read and write to the xml file?
If so, it sets some alarms bells ringing for me, as you stated, file locks, concurrancy etc. From my experience using files as essentially a database brings trouble, especially when the file is on a network share somewhere. I could well be missing something though, as I said before, Ive never really used xml files
Im tempted to have a simple SQL table, with an incrementing unique ID, and a quick insert of say the ACT contact guid. Then all locks and transactions are sorted out by SQL internally. I know it seems fairly elaborate just to get a ticket number! It still baffles me as to why there isnt some unique custom field option in ACT...
Anyhow, please let me know your thoughts, and thanks again for the valuable input
07-16-2010 07:33 PM - edited 07-16-2010 07:36 PM
is the field was a number field only, you could do a SQL query that returns the max number found in all contacts and from that add one
something like SELECT max(fieldname) from table.. it then finds the highest value in all the records and returns that