Forum Discussion

Keyser_Soze's avatar
Keyser_Soze
Contributor
11 months ago

Get Account Type as Integer From String

Hello There, Is there a way to get the 'Integer' behind each Account Type based on a 'String' ? Context: I am trying to create new Account Members with pre-defined properties, all properties wer...
  • JackLacava's avatar
    11 months ago

    Off the top of my head:

    Function GetAccountTypeByName(ByRef accTypeName as String)
    	try:
    		return AccountType.GetItem(accTypeName)
    	catch ex as Exception:
    		throw ErrorHandler.LogWrite(si, new XFException(si, ex))
    	end try
    end function
    

    That gives you back an AccountType object, which is a bit more flexible. Then in your main code you can use it like this:

     AccProperties.AccountType.SetStoredValue( GetAccountTypeByName("Flow").Id )