SPFieldWorkflowStatus.Init method
Inicializa o objeto SPFieldWorkflowStatus .
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaração
Public Sub Init ( _
strUrl As String, _
strShowField As String _
)
'Uso
Dim instance As SPFieldWorkflowStatus
Dim strUrl As String
Dim strShowField As String
instance.Init(strUrl, strShowField)
public void Init(
string strUrl,
string strShowField
)
Parâmetros
strUrl
Type: System.StringA URL de uma página de status do fluxo de trabalho personalizado. O padrão é _layouts/WrkStat.aspx.
strShowField
Type: System.StringO nome do campo a ser exibido. O padrão é Status1.
Comentários
Esse método define o atributo WorkflowStatusURL e o atributo ShowField da definição de elemento de campo e define a propriedade ReadOnlyField do campo como true.
Examples
O exemplo a seguir é um aplicativo de console que adiciona um campo WorkflowStatus à lista chamada Test List e inicializa o campo.
O aplicativo requer que o site tem uma lista de chamada "Test List" e o modelo de pelo menos um fluxo de trabalho.
Imports System
Imports System.Collections.Specialized
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Workflow
Module ConsoleApp
Sub Main()
Using site As SPSite = New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
Dim list As SPList = web.Lists("Test List")
Dim workflowTemplate As SPWorkflowTemplate = web.WorkflowTemplates(0)
Dim choices As StringCollection = workflowTemplate.GetStatusChoices(web)
Dim fldName As String = list.Fields.Add("Workflow Status", _
SPFieldType.WorkflowStatus, False, True, choices)
Dim statusUrl As String = workflowTemplate.StatusUrl
Dim fld As SPFieldWorkflowStatus = CType(list.Fields.GetFieldByInternalName(fldName), _
SPFieldWorkflowStatus)
fld.Init(statusUrl, Nothing)
fld.Update()
Console.WriteLine("Field {0} {1} read-only.", fldName, IIf(fld.ReadOnlyField, "is", "is not"))
End Using
End Using
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using System.Collections.Specialized;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Test List"];
SPWorkflowTemplate workflowTemplate = web.WorkflowTemplates[0];
StringCollection choices = workflowTemplate.GetStatusChoices(web);
string fldName = list.Fields.Add("Workflow Status",
SPFieldType.WorkflowStatus, false, true, choices);
string statusUrl = workflowTemplate.StatusUrl;
SPFieldWorkflowStatus fld = list.Fields.GetFieldByInternalName(fldName) as SPFieldWorkflowStatus;
fld.Init(statusUrl, null);
fld.Update();
Console.WriteLine("Field {0} {1} read-only.", fldName, fld.ReadOnlyField ? "is" : "is not");
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
}
Ver também
Referência
Microsoft.SharePoint namespace