Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Get User Name with Domain Name

  • Last UpdatedJun 10, 2024
  • 1 minute read

In scenarios where you want to get the user name in the format <domain name>\<user name>, you can use the below options based on the requirement.

  • For User interface, use UserContext.GetUserName.

  • To use inside an activity, use Context.DownLevelLogOnName. This method can be used in expressions based on the requirement and criteria.

    DownLevelLogOnName is for getting the user name with domain name in run time. The following code sample demonstrates how to use DownLevelLogOnName in action run method. For example, adding a new variable in the variable collection with DownLevelLogOnName and assigning the value at runtime.

    {

    try

    {

    string customActivityPropertyValue = "";

    VariablesCollection variables = CurrentContext.Variables;

    if (variables.Contains("DownLevelLogOnName"))

    {

    Workflow.NET.Variable Var = variables["DownLevelLogOnName"];

    Var.Value = CurrentContext.DownLevelLogOnName.ToString();

    }

    else

    {

    variables.Add("DownLevelLogOnName", "string", CurrentContext.DownLevelLogOnName.ToString());

    }

    CurrentContext.log.LogInformation("Testing DownLevelLogOnName value :" + CurrentContext.DownLevelLogOnName.ToString());

    Output = "Success";

    }

    catch

    {

    Output = "UnSuccess";

    }

    return ActionResult.Completed;

    }

Related Links
TitleResults for “How to create a CRG?”Also Available in