If args.FunctionName.XFEqualsIgnoreCase("ReturnEntityFromWFName") Then Dim WFProfileName As String = args.NameValuePairs.XFGetValue("WFProfile") Dim entityName As String = ...derive entity name from WFProfileName string...
Return entityName
End if
As for assigned entities, you can use a bound list parameter (as more than one entity may be assigned):
Select a profile with assigned entities and then run the parameter to see what it returns exactly: