カスタムワークフローアクティビティまたはプラグインの環境変数へのアクセス
6361 ワード
導入
環境変数は、それぞれの環境で異なるグローバル変数を格納する素晴らしい方法です.いくつかの一般的なユースケースでは、AppIDを格納しているので、データを格納している場合は、SharePointサイトのURLで参照することができます.これらは、EnvironmentVariableDefinitionとEnvironmentVariableValueテーブルの下にあるDataVerseに格納されます.
彼らはパワー自動化に組み込まれているし、比較的簡単にアクセスすることができますが、伝統的なプラグインやカスタムワークフローの活動でそれらを参照する必要がある場合は、それらを取得するfetchXMLを使用する必要があります.
コードスニペット
protected override void Execute(CodeActivityContext context)
{
try
{
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
// Use the context service to create an instance of IOrganizationService.
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.InitiatingUserId);
string appID = GetEnvironmentVariable(service, "appID");
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.ToString());
}
}
private string GetEnvironmentVariable(IOrganizationService service, string envVariableName)
{
string fetchXml = string.Empty;
EntityCollection result = null;
string envVariableValue = string.Empty;
fetchXml = String.Format(@"<fetch version=""1.0"" output-format=""xml-platform"" mapping=""logical"" distinct=""false"">
<entity name=""environmentvariablevalue"">
<attribute name=""environmentvariablevalueid"" />
<attribute name=""value"" />
<link-entity name=""environmentvariabledefinition"" from=""environmentvariabledefinitionid"" to=""environmentvariabledefinitionid"" link-type=""inner"">
<attribute name=""displayname"" />
<filter type=""and"">
<condition attribute=""displayname"" operator=""eq"" value=""{0}"" />
</filter>
</link-entity>
</entity>
</fetch>", envVariableName);
result = service.RetrieveMultiple(new FetchExpression(fetchXml));
if (result != null && result.Entities.Count > 0)
{
envVariableValue = result.Entities[0].GetAttributeValue<string>("value");
}
return envVariableValue;
}
解説
したがって、Outputメソッドでは、標準クラスのBoilerPlateコードを使用してDataBaseseにアクセスできるクラスを取得します.
getenvironmentvariableメソッドの中に、本当にすべての行動があるところです.この関数はenvvariablenameと呼ばれるパラメータを受け取り、fetchXMLを使って呼び出しを行い、その名前で環境値を取得します.
Reference
この問題について(カスタムワークフローアクティビティまたはプラグインの環境変数へのアクセス), 我々は、より多くの情報をここで見つけました
https://dev.to/diskdrive/accessing-environment-variables-in-your-custom-workflow-activity-or-plugin-2j45
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
protected override void Execute(CodeActivityContext context)
{
try
{
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
// Use the context service to create an instance of IOrganizationService.
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.InitiatingUserId);
string appID = GetEnvironmentVariable(service, "appID");
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.ToString());
}
}
private string GetEnvironmentVariable(IOrganizationService service, string envVariableName)
{
string fetchXml = string.Empty;
EntityCollection result = null;
string envVariableValue = string.Empty;
fetchXml = String.Format(@"<fetch version=""1.0"" output-format=""xml-platform"" mapping=""logical"" distinct=""false"">
<entity name=""environmentvariablevalue"">
<attribute name=""environmentvariablevalueid"" />
<attribute name=""value"" />
<link-entity name=""environmentvariabledefinition"" from=""environmentvariabledefinitionid"" to=""environmentvariabledefinitionid"" link-type=""inner"">
<attribute name=""displayname"" />
<filter type=""and"">
<condition attribute=""displayname"" operator=""eq"" value=""{0}"" />
</filter>
</link-entity>
</entity>
</fetch>", envVariableName);
result = service.RetrieveMultiple(new FetchExpression(fetchXml));
if (result != null && result.Entities.Count > 0)
{
envVariableValue = result.Entities[0].GetAttributeValue<string>("value");
}
return envVariableValue;
}
解説
したがって、Outputメソッドでは、標準クラスのBoilerPlateコードを使用してDataBaseseにアクセスできるクラスを取得します.
getenvironmentvariableメソッドの中に、本当にすべての行動があるところです.この関数はenvvariablenameと呼ばれるパラメータを受け取り、fetchXMLを使って呼び出しを行い、その名前で環境値を取得します.
Reference
この問題について(カスタムワークフローアクティビティまたはプラグインの環境変数へのアクセス), 我々は、より多くの情報をここで見つけました
https://dev.to/diskdrive/accessing-environment-variables-in-your-custom-workflow-activity-or-plugin-2j45
テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol
Reference
この問題について(カスタムワークフローアクティビティまたはプラグインの環境変数へのアクセス), 我々は、より多くの情報をここで見つけました https://dev.to/diskdrive/accessing-environment-variables-in-your-custom-workflow-activity-or-plugin-2j45テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol