Get User Account by email address

Hi,

I have an object that contains two properties related to this post. One is an email address that is pulled in via a mail source subject line into the email Address field when the object is created. The other property User (Value List of Users). I want to create an automatic value for the User Property I created (the property is called internal customer name and uses the User Value List).

So I have an email address from the email that creates the object. All of these emails come from M-Files users, therefore, the email address that it pulls in should match a login account.

I want to create a script for the automatic value of the Internal Customer Name(M-Files User) based off of the email address that the email comes from. I have written some code for the automatic value of this property, but nothing seems to be happening when it recalculates. Any help would be appreciated.

Option Explicit

'Get the Email from current object
dim Email : Email = vault.objectpropertyoperations.getproperty(Objver, 1798).value.displayvalue



Dim i, j, Account, User, UserAccount, UserName


for i = 1 to Vault.UserOperations.GetLoginAccounts.Count


	if Vault.UserOperations.GetLoginAccounts.item(i).EmailAddress = Email then

	
	for j = 1 to Vault.UserOperations.GetUserAccounts.count

		if Vault.UserOperations.GetUserAccount.item(j).LoginName = Vault.UserOperations.GetLoginAccounts.item(i).AccountName then

			
		
			output = Vault.UserOperations.GetUserAccount.item(j).LoginName
			
		end if
	next
		
	end if


next

  • I was able to get this to work. Code is below:

    Option Explicit
    
    'Get the Email from current object
    dim Email : Email = vault.objectpropertyoperations.getproperty(Objver, 1798).value.displayvalue
    
    
    
    Dim i, UserID
    
    
    for i = 1 to Vault.UserOperations.GetUserAccounts.Count
    
    UserID = Vault.UserOperations.GetUserAccounts.item(i).ID
    
    	If Vault.UserOperations.GetUserAccounts.item(i).enabled = true then
    		
    			'On Error resume next
    			If Vault.UserOperations.GetLoginAccountOfUser(UserID).Enabled = True then
    				if Vault.UserOperations.GetLoginAccountOfUser(UserID).EmailAddress <> "" then
    			
    			
    				if uCase(Vault.UserOperations.GetLoginAccountOfUser(UserID).EmailAddress) = uCase(Email) then
    
    					
    					output = Vault.UserOperations.GetUserAccount(UserID).ID
    			
    					
    				end if
    			end if
    		end if
    	end if
    
    next