none
can anyone advice on how i can prevent my Global Workflow from showing a Status fields inside the lists views? RRS feed

  • Question

  • I have created a global workflow 2010 using sharepoint designer 2013. and i link the global workflow with a custom content type.

    now i am facing a problem is that whenever i create a new item inside a list which uses the custom content type . the global workflow will show the following status field:-

    so can anyone adivce how i can prevent the global workflow from creating such a status field on any new lists?

    second point. if this can not be achieved using sharepoint out of the box options. then can anyone advice if i can hide this column using power-shell script? where i can write a power shell script which loop through the lists' views and if the workflow status filed is shown inside the list view to hide it ? where i can call this powershell script each let say 15 minutes?

    Wednesday, January 4, 2017 1:58 AM

All replies

  • Try "Modify view" - OOTB and remove the specific field from the view.

    https://support.office.com/en-us/article/Create-change-or-delete-a-view-of-a-list-or-library-27ae65b8-bc5b-4949-b29b-4ee87144a9c9 

    Wednesday, January 4, 2017 12:14 PM
  • Try "Modify view" - OOTB and remove the specific field from the view.

    https://support.office.com/en-us/article/Create-change-or-delete-a-view-of-a-list-or-library-27ae65b8-bc5b-4949-b29b-4ee87144a9c9 


    i can do this for the current view/s but i need this to be prevented on any new list/view... is there a way to do so ?
    Wednesday, January 4, 2017 2:57 PM
  • Hi john,

    The following PowerShell script for your reference:

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
    
    #Function: sharepoint powershell delete field from view
    Function Remove-FieldFromView([Microsoft.SharePoint.SPList]$List, [String]$ViewName, [string]$FieldInternalName)
    {
    	#Get the view
    	$View = $List.Views[$ViewName]
    	
    	#To Get the Default View: List.DefaultView    
    	if($view -eq $Null) {write-host "View doesn't exists!" -f Red; return}  
    	
    	#Check if view has the specific field already!
    	if($view.ViewFields.ToStringCollection().Contains($FieldInternalName))
    	{
    		#Remove field from view: 
    		$View.ViewFields.delete($FieldInternalName)
    		$View.Update()
    		write-host "Field Removed from the View!" -f Green
    	}
    	else
    	{
    		write-host "Field Doesn't Exists in the view!" -f Red
    	}
    }
    
    
    #configuration parameters
    $WebURL="https://portal.crescent.com/projects/"
    $ListName="Project Milestones"
    $ViewName="All Items"
    $FieldName="ProjectDescription"
    
    #Get the Web and List
    $Web= Get-SPWeb $WebURL
    $List = $web.Lists.TryGetList($ListName)
    
    #Call the function to remove column from view 
    Remove-FieldFromView $List $ViewName $FieldName

    More information is here:

    http://www.sharepointdiary.com/2015/11/remove-field-from-view-in-sharepoint-using-powershell.html

    Or if you don't want to use the workflow column, we can delete it from list.

    Remove workflow column from SharePoint List

    http://techno-sharepoint.blogspot.sg/2013/03/remove-workflow-column-from-sharepoint.html

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, January 5, 2017 9:25 AM
    Moderator
  • Hi john,

    The following PowerShell script for your reference:

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue 
    
    #Function: sharepoint powershell delete field from view
    Function Remove-FieldFromView([Microsoft.SharePoint.SPList]$List, [String]$ViewName, [string]$FieldInternalName)
    {
    	#Get the view
    	$View = $List.Views[$ViewName]
    	
    	#To Get the Default View: List.DefaultView    
    	if($view -eq $Null) {write-host "View doesn't exists!" -f Red; return}  
    	
    	#Check if view has the specific field already!
    	if($view.ViewFields.ToStringCollection().Contains($FieldInternalName))
    	{
    		#Remove field from view: 
    		$View.ViewFields.delete($FieldInternalName)
    		$View.Update()
    		write-host "Field Removed from the View!" -f Green
    	}
    	else
    	{
    		write-host "Field Doesn't Exists in the view!" -f Red
    	}
    }
    
    
    #configuration parameters
    $WebURL="https://portal.crescent.com/projects/"
    $ListName="Project Milestones"
    $ViewName="All Items"
    $FieldName="ProjectDescription"
    
    #Get the Web and List
    $Web= Get-SPWeb $WebURL
    $List = $web.Lists.TryGetList($ListName)
    
    #Call the function to remove column from view 
    Remove-FieldFromView $List $ViewName $FieldName

    More information is here:

    http://www.sharepointdiary.com/2015/11/remove-field-from-view-in-sharepoint-using-powershell.html

    Or if you don't want to use the workflow column, we can delete it from list.

    Remove workflow column from SharePoint List

    http://techno-sharepoint.blogspot.sg/2013/03/remove-workflow-column-from-sharepoint.html

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    I always prefer to write this using a managed code, so i changed your appraoch to be as follow by creating a console application :-

    try
                {
                    using (SPSite site = new SPSite(scurl))  //site collection url
                    {
                        using (SPWeb web = site.OpenWeb(subsiteurl0)) //specific subsite url
                        {
                            SPWebCollection subWebs = web.Webs; //get all sites under specific subsites
    
                            foreach (SPWeb subSite in subWebs)
                            {                         
                                //Write-Host $web.title ": " $web.URL      ;   
                                var l = subSite.Lists;                         
                                for (int i = 0; i < l.Count; i++)
                                {
                                    var defaultview = l[i].DefaultView;
                                    if (defaultview != null)
                                    {
                                        if (defaultview.ViewFields.SchemaXml.Contains("global1"))
                                        {
                                            defaultview.ViewFields.Delete("global1"); // #use internal column name
                                            defaultview.Update();
                                        }
                                        if (defaultview.ViewFields.SchemaXml.Contains("global2"))
                                        {
                                            defaultview.ViewFields.Delete("global2"); // #use internal column name
                                            defaultview.Update();
                                        }
                                        
                                    }
                                }
                            }
                        }
                    }
                }

    now i am planning to schedule this using windows scheduler and force it to run each hour or maybe less. but my only concern is what is the exact effect of running such a code? will it be exactly similar to modifying a list view and then un-check the workflow status columns "global1" & "global2" in my case ? is this code considered safe ?

    Thursday, January 5, 2017 11:39 PM