Reply
New Member
mark101
Posts: 10
Country: Ireland
Message 1 of 7 (2,314 Views)

Unique ID in Custom Field

Hi All

 

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...

 

Thanks

Mark

Please use plain text.
New Member
mark101
Posts: 10
Country: Ireland
Message 2 of 7 (2,314 Views)

Re: Unique ID in Custom Field

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?

 

Thank you! 

Please use plain text.
Bronze Super Contributor
vivek
Posts: 1,739
Country: United_Kingdom
Message 3 of 7 (2,305 Views)

Re: Unique ID in Custom Field

Hi Mark,

 

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();

doc.LoadXml("<Setting><LastTicketNo>"+count.ToString()+"</LastTicketNo></Setting>"); 

doc.Save(@"D:\settings.xml");

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");
while (reader.Read())
{
if(reader.NodeType==XmlNodeType.Text)
MessageBox.Show(reader.Value);
}
reader.Close();

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! :smileysurprised:

 

HTH

 

Vivek

 

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Please use plain text.
New Member
mark101
Posts: 10
Country: Ireland
Message 4 of 7 (2,300 Views)

Re: Unique ID in Custom Field

Hi Vivek

 

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

Mark 

Please use plain text.
Bronze Super Contributor
vivek
Posts: 1,739
Country: United_Kingdom
Message 5 of 7 (2,291 Views)

Re: Unique ID in Custom Field

Hi Mark,

Sorry about not being clear you caught me out being a bit lazy! :smileytongue: 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.

 

HTH

Vivek.

Vivek Gargav
Caldere Associates Ltd.
www.caldere.com
vgargav@caldere.com
My Blog
Please use plain text.
New Member
mark101
Posts: 10
Country: Ireland
Message 6 of 7 (2,288 Views)

Re: Unique ID in Custom Field

Hi Vivek

 

No, your explanation was good thanks, and laziness is my forte :smileyhappy:

 

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

 

Mark 

Please use plain text.
Copper Super Contributor
ozie
Posts: 112
Country: Australia
Message 7 of 7 (922 Views)

Re: Unique ID in Custom Field

[ Edited ]

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

Please use plain text.