Book a Demo

Author Topic: How to get Author GUID for use with ModelMailInterface  (Read 3735 times)

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
How to get Author GUID for use with ModelMailInterface
« on: March 17, 2020, 10:33:56 pm »
Hi,

Is there a way to get the Author GUID for use as the first argument of the ModelMailInterface.ComposeMailMessage class? I can get an Author class, based on the Author of an element. But the class doesn't contain the GUID.

Thanks,

Jon.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: How to get Author GUID for use with ModelMailInterface
« Reply #1 on: March 18, 2020, 12:09:48 am »
Hi Jon,


Couple things here.
1) Authors don't have GUIDs. The class matches the table (t_authors).
2) MailInterface.ComposeMailMessage() references a SecurityUser, not an Author.
3) SecurityUsers do have GUIDs... But they're not available in the API. :/

So you'll need to fetch it from the database. t_secuser.UserLogin is unique (not sure if it's key in the schema, but two accounts can't share the same login name) and should correspond to SecurityUser.Login, while t_secuser.UserID holds the GUID.

I say "should" because I haven't tested it and SecurityUser is a little odd in that not only does it omit the GUID but it also has a .FullName property which doesn't appear in the database. Presumably it's a concatenation of .FirstName and .Surname, but I'd be interested to know if it actually works correctly given that the correct order for a person's name depends on the language. Or maybe that's actually a misnamed GUID property? Probably worth checking.

All that said, the Element.Author property is free text, not a reference. Furthermore, the value EA uses to set this property when you create an element is configured in the client. By default, it's set from the login data but it can be overridden. And if you import logins from the AD, whether t_author rows are created when importing users is selected during the import (so it's not even a project setting).

In other words, there is no guarantee that
a) you'll find Element.Author in t_authors, or that
b) you'll find it in t_secuser.

So if you want to send an in-EA mail to the author of an element, you'll need to take those cases into account.

HTH,


/Uffe
My theories are always correct, just apply them to the right reality.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: How to get Author GUID for use with ModelMailInterface
« Reply #2 on: March 19, 2020, 02:49:25 am »
Hi,

Thanks for the feedback. My question was stated incorrectly. I found the answer I was after:

GUID = theMailInterface.GetRecipientGUID(theElement.Author)
result = theMailInterface.ComposeMailMessage(GUID, msgTitle, mfRed, msg)

where theElement is an EA.Element.