Update workflow status column using PowerShell
Hi All,
Using PowerShell i want to update the 'Document Status' column as 'Approved' if it is 'Pending' when it is approved and Task Status is = 'Completed'
Intermittently my custom workflow is not updating the 'Document Status' column as 'Approved' though it is approved and Task Status is = 'Completed'
So I thought about running a PowerShell script to work around it.
Can you please help me for the script.
Thanks & Regards
MD.Liakath ali
Hi,
The following PowerShell script for your reference:
$SPWeb = Get-SPWeb http://site
$List = $SPWeb.Lists["ListName"]
$items = $List.Items
foreach ($item in $items) {
$taskStatus = $item["Task Status"]
$docStatus = $item["Document Status"]
if ($taskStatus -eq "Completed" -and $docStatus -eq "Pending")
$item["Document Status"] = "Approved"
$item.Update()
$list.Update()
$SPWeb.Dispose()
If the 'Document Status' column is "Approval Status" column and your workflow is an approval workflow, the following articles may be helpful:
Approval workflow does not update the approval status of items
https://kanithi.wordpress.com/2014/03/13/approval-workflow-does-not-update-the-approval-status-of-items/
SharePoint 2010 Approval Workflow with Content Approval
https://eointherealworld.wordpress.com/2010/12/29/sharepoint-2010-approval-workflow-with-content-approval/
Best Regards
Dennis Guo
TechNet Community Support
Similar Messages
-
SPD 2013 WorkFlow Status Column: Status Not Updated
We are having an issue with the status display of the SPD Designer Workflow status column which is a read only column added by SharePoint to show the status of the workflow. We have some SharePoint 2013 Workflows built using SharePoint Designer that are
attached to specific SharePoint Document Libraries. The expected behavior is for this column to show the workflow statuses (Not Started, Starting Workflow, In Progress and Completed.
Based on our observation this status is showing up although the column does get added for the Workflow that we have. Is there any other dependency for SPD Workflows that are attached to Document Libraries to show the status correctly? Any other settings/configurations
to be made?
Regards,
Vikram
Blog: http://dotnetupdate.blogspot.com |Hi Venkadesh,
It is by design that 2013 workflow will show stage name in the workflow status column when
Automatically update the workflow status to the current stage name is checked.
And the workflow status column will be blank when Automatically update the workflow status to the current stage name is unchecked.
For existing workflows, the workflow status will still exists with the previous values after unchecking Automatically update the workflow status to the current stage name.
We can use Set Workflow Status action to update the workflow status value based on our needs.
Best regards,
Victoria
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
Move workflow status column from one library to another in Sharepoint 2010
Good morning,
I have two libraries in the same site, LibraryA and LibraryB.
On LibraryA, users upload documents upon which they start a collect signatures workflow. The view on LibraryA contains a column with the signatures workflow name showing status: ‘Compete’, ‘In progress’.
Now on LibraryA I have created a workflow to move any document one month after creation to LibraryB (using retention schedule) irrespective of signature workflow status.
Now what I would like is to have the signature workflow status shown in LibraryB as well. From what I understand you can add the workflow status column only on the library with which the workflow is associated. I also tried, on LibraryB, to create a new
column which Lookups in {Signature Approval History – Outcome} but this did not do the trick either.
Any workarounds?
Many ThanksHi,
According to your description, my understanding is that you want to move the workflow status column to another library in SharePoint 2010.
I recommend to use another column to get the value of the workflow status column and then move this column to another library.
We can use workflow to update the column with the value of workflow status column.
However, the workflow status column stores the value with numbers which represent different status, so we need to update the column with corresponding status based on the numbers in the workflow.
http://chanakyajayabalan.wordpress.com/2010/03/08/sharepoint-workflow-status-codes/
Best regards.
Thanks
Victoria Xia
TechNet Community Support -
Workflow Status column for new content type
Hi,
Initially I had a document library and several workflows associated with it. After that I created a new content type inheriting Folder content type. My existing workflows could be started and work fine with any item of this new content type except anything
related to the workflow status column, such as "Automatically update workflow status to the current stage name", or workflow action "Set workflow status". If I use the OOTB Folder content type, everything's fine. But I need custom fields
for folder as well.
The workflows can be started then it seems unreasonable that they are not associated with the items of the new content type, considering I set my new content type to be the child of the existing Folder content type. So why any item under this new content
type does not have the workflow status column? I've tried removing the workflow from the list and publishing back using SPD without success.
I also notice that when you associate a new content type to a document library/list which has some custom columns, you cannot edit those columns to be used in the new content type. You need to delete those columns and recreate them, then the option "Add
to all content types" is there. Is this expected design?
ThanksHi,
According to your post, an error occurred when you created a custom Edit form for new content type.
We can do as follows:
1.Add the MyNameSpace.MyNewEditPage dll file into GAC(C:\Windows\assembly).
2. Execute the iisreset command.
We can create a new content type using visual studio 2012/2013.
http://www.sharepoint-journey.com/sharepoint-list-content-types-and-site-columns.html
Best Regards
Dennis Guo
TechNet Community Support -
I've created SPD 2013 workflow and deployed them onto that document library, This workflow execute on item update event. When updating library item, workflow triggered and completed successfully but workflow status column is not
showing the Internal Status values rather it is showing the Stage information. I've unchecked the "Automatically update stage name on workflow status" and republished the workflow. After that, it is still showing the stage information. Any help
is really appreciated.Hi Venkadesh,
It is by design that 2013 workflow will show stage name in the workflow status column when
Automatically update the workflow status to the current stage name is checked.
And the workflow status column will be blank when Automatically update the workflow status to the current stage name is unchecked.
For existing workflows, the workflow status will still exists with the previous values after unchecking Automatically update the workflow status to the current stage name.
We can use Set Workflow Status action to update the workflow status value based on our needs.
Best regards,
Victoria
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
How can we access workflow status column out of the box (OOTB).
I have a problem that few of the workflows in production are failed at last stage have status set to "Workflow Errored". Someway I have fixed issue with workflow but I need to modify this status.
I tried adding a custom column and access workflow status column so that I can modify custom column as I want, and show this in views.
But I can't access this without using code, anybody has any idea?
My task is to modify workflow status which are errored out.You can rerun the workflow once you've fixed it up. This'll change the status to something more successful.
Steven Andrews
SharePoint Business Analyst: LiveNation Entertainment
Blog: baron72.wordpress.com
Twitter: Follow @backpackerd00d
My Wiki Articles:
CodePlex Corner Series
Please remember to mark your question as "answered" if this solves (or helps) your problem. -
Workflow status column in AllUserData Table with wrong coded in Content Database?
I would like to write a stored procedure to find out all workflow instances with errors, directly from content database.
I go to dbo.alllists to find out the workflow status column, and query AllUserData and find out not readable text
like:
쳀曩쌙䂻֞鼥
㖦巀䐝义颹暲ﻇൿ
ﱰ臨臸䋖ហ嬀ᨵ瘉
鄌幀鴏䔖튅㐻⩷揬
묨ή姖䩡ꊎ鉛۬浶
⟯봨飮䙕잳摕盜⣢
屑䳬鑥䶵岿珽磯Â
ꬁᆈ䀥䓝䶲紀篰䟫
蓏ꋦ䥌肃瘓⯈᭄
뵎㎙䈸䪿蔀ࢴ
෬꧋辂䘀馻ࡲ琓
ꞎ鵫䬺ࢬ䀒✫ꡱ
any ideas?Hi,
Thanks to share your post.
For the issue, I think it may due to the wrong handling of the encoding type “UTF-8”, please refer to the followed article, they may give you a hand:
http://blogs.sun.com/shankar/entry/how_to_handle_utf_8.
http://devlog.info/2008/08/24/php-and-unicode-utf-8/.
Hope this could help you!
Leo -
Check the type of column using powershell within a splist
hi,
i have a column called BU in my splist in many site collections.i had created using with lookup datatype and now since my design is changed i want to create this as a a choice field with few default values. Can anyone please
help how to check this using powershell? i mean check the datatype of column using PS and if its lookup then need to delete the list and recreate it with choice field. i know hot to create a splist with choice field using PS,
but i am unable to get the code for existence of lookup or choice field.
$web = Get-SPWeb "http://sitename"
$fieldnamebu= "BU"
$mysplist = $web.lists["mysplist1"]
$lookupfieldA="Lookup"
foreach($sfield in $mysplist.fields)
# how to check the datatype pf column as lookup
if ( ##todo#### -eq $lookupfieldA )
$mysplist.Delete();
$web.upate();
create the splist with choice field$spTemplate = $web.ListTemplates["Custom List"] #Create SPTemplate instance of Type Custom List
$web.Lists.Add("mysplist1", "for approvers", $spTemplate) #Add list to site$spList = $spWeb.Lists["mysplist1"] #Get list instance
$spList.OnQuickLaunch = $True $spList.Update() #Update list to reflect changes in site
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text #Get Field type to create
$spList.Fields.Add("Mymn", $spFieldType, $false) #Add new field to list}HI,
To get the field types please refer below link...
foreach ($field in $list.Fields) #Get all fields in lists
if($spField -eq $field.Title) #if field in lists equals field in views
Write-Host $spField " | " $field.Type -ForegroundColor Green #Write out each field (column)
https://gallery.technet.microsoft.com/office/SharePoint-Get-SPFields-49039dc0
To Create Choice field follow below reference:
https://social.msdn.microsoft.com/Forums/en-US/8a874677-91cf-41dd-a601-f0dd7fdce213/creating-a-choice-column-via-powershell
http://adicodes.com/add-fields-to-list-with-powershell-in-sharepoint-2010/
Don't
forget to mark it as an Answer if it resolves your issue and Vote Me as helpful if it useful.
Mahesh -
Send Email when built in approval workflow status column changes to approved
I Implemented the built in approval work flow in a document library,I want to send an email when the column indicating the status of the workflows changes from in progress to approved.
Hi ,
According to your description, my understanding is that you want to send email when the built-in approval workflow status was approved.
For the default built-in approval workflow, per my knowledge, there is not a way to modify it. As a workaround, you can create a Reusable Workflow with SharePoint Designer 2010, and publish it to your SharePoint, then you can use it like the built-in approval
workflow.
You can do as the followings:
Install SharePoint Designer 2010.
Open your site with SharePoint Designer 2010.
Click Workflow under Navigation.
Click Reusable Workflow, and type a name.
Add “Start Approval Process” action, in the ‘these user’ , type the approvers.
Click ‘Approval’ field, and under Customization, click “Change the behavior of a single task”.
On the “When a Task Completes”, add “Send an Email” action in the approved condition,like the screenshot below.
Then save and publish the workflow, then you can use the workflow in your SharePoint site .
I hope this helps.
Thanks,
Wendy
Wendy Li
TechNet Community Support -
Creating look up column using powershell.
I have a Sharepoint list "Studentparent" in my website. I am trying to create a custom list "studentchild" list using powershell code and this studentchild list will be having a look up column getting ID column from "StudentParent"
list - So the code is
#To which site u want to create the list
$spWeb=Get-SPWeb -Identity http://XYZ
#List type or template
$spTemplate = $spWeb.ListTemplates["Custom List"]
#Get all the lists to the listcollection
$spListCollection=$spWeb.Lists
#adding the new list to the list collection
$spListCollection.Add("StudentChild","StudentChild",$spTemplate)
#get the path of subsite and sitecollecion
$path = $spWeb.url.trim()
#get the list to the list object
$spList = $spWeb.GetList("$path/Lists/StudentChild")
$ParentList = $spWeb.Lists.item("StudentParent")
$spList = $WebObj.Lists["StudentChild"]
$spList.Fields.AddLookup("ChildLookupField",$ParentList.id,$false)
$spChildListLookupField = $spList.Fields["ChildLookupField"]
$spChildListLookupField.LookupField = $ParentList.Fields["ID"]
$spChildListLookupField.RelationshipDeleteBehavior = [Microsoft.SharePoint.SPRelationshipDeleteBehavior]::Restrict
$spChildListLookupField.Update()
$Views = $spList.Views["All Items"]
$Views.ViewFields.Add("ChildLookupField")
$Views.Update()
but when i run this code - I am getting error
Cannot index into a null array.
+ $spList = $WebObj.Lists["StudentChild"]Hi Mahesh,
The object "$WebObj" is not instantiated in your code. You have already assigned the value to $splist in following line.
$spList = $spWeb.GetList("$path/Lists/StudentChild")
and once again you are assigning value
$spList = $WebObj.Lists["StudentChild"] // redundant and it should be $spWeb.Lists["StudentChild"]
Please let us know if this fixes your issue.
Thanks,
M. Gubendra Raj -
Guys,
I need to update table A columns col3, col4, col5 and col6 by table b columns col3, col4, col5 and col6 however table b col5 and col6 values need to come from table c col1.
Means table b col5 and col6 have values in it however i need to replace them with value from table c col1 and need to update table a col5 and col6 accordingly.
table a and table b has col1 and col2 in common.
i am trying something like this.
Update a
a.col3 = b.col3,
a.col4 = b.col4,
a.col5 = (select col1 from table_c c where c.col2=b.col5),
a.col6 = (select col1 from table_c c where c.col2=b.col6)
from table_A a inner join table_b
on a.col1=b.col1 and a.col2=b.col2
can someone help me reframe above update query?
thanks in advance for your help.Try the below:(If you have multiple values, then you may need to use TOP 1 as commented code in the below script)
create Table tableA(Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int)
Insert into tableA values(1,2,3,4,5,6)
create Table tableB(Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int)
Insert into tableB values(1,2,30,40,50,60)
create Table tableC(Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int)
Insert into tableC values(100,50,30,40,2,2)
--Insert into tableC values(200,50,30,40,2,2)
Insert into tableC values(100,60,30,40,2,2)
Select * From tablea
Update a Set
a.col3 = b.col3,
a.col4 = b.col4,
a.col5 = (select col1 from tablec c where c.col2=b.col5 ),
a.col6 = (select col1 from tablec c where c.col2=b.col6 )
from tableA a inner join tableb b
on a.col1=b.col1 and a.col2=b.col2
--Update a Set
--a.col3 = b.col3,
--a.col4 = b.col4,
--a.col5 = (select Top 1 col1 from tablec c where c.col2=b.col5 Order by c.Col1 asc),
--a.col6 = (select Top 1 col1 from tablec c where c.col2=b.col6 Order by c.Col1 asc)
--from tableA a inner join tableb b
--on a.col1=b.col1 and a.col2=b.col2
Select * From tablea
Drop table tablea,Tableb,TableC -
Updating a CLOB column using C++ with ATL
Hello,
I have tables with a single CLOB or BLOB colum with the rest of the columns of type VARCHAR2.
I'm getting a result of E_FAIL when updating a single row, for which I'm attempting to change one of the VARCHAR2 columns and the CLOB column. If I set the status for the CLOB column to DBSTATUS_S_IGNORE, the update succeeds (for the other column). If I set the status for all other columns to DBSTATUS_S_IGNORE and the status for the CLOB column to DBSTATUS_S_OK, it still fails.
If I use a SQL Server data source with the same schema and the same C++ code, the original update succeeds.
The length of the data I'm attempting to store is 11487 characters.
As near as I can tell, the Oracle provider does support this kind of functionality. Perhaps there is some coding variation needed for the Oracle data source. I have so far been unable to find a suitable example (or any code example for the Oracle provider using C++/ATL).
I'm using Oracle 9i Release 2 with the latest OLE DB provider (9.2.0.2.0).
Thanks,
Daniel E. Hale
[email protected]Some additional information on the problem:
I was using the ISequentialStream interface
with a Dynamic Accessor when the problem
occurred.
Since then I've tried using a SQL command to do
the update... and I've found the 11487 characters
is too long... I get a maximum length error when
I try the command in SQL+. (BTW, SQL Server works
fine with the long command.)
I doubt that the length is the reason for the failure
of the update using the ISequentialStream interface.
I'm just looking for something that works. Right
now, the only thing that works is not to do the
update at all, but instead do delete/insert. I'd
like to find a better solution than that.
-Daniel E. Hale -
Update multiple rows & columns using a single statement
I have the following table with tablename - emp
first_name last_name age
aaa bbb 31
56
78
ggg hhh 36
2nd & 3rd row contain null values (no data) in first_name & last_name column . I want to update those two rows with data using a single statement. How do I do it?
I was thinking may be something like the following:-
UPDATE emp
SET first_name= , last_name=
CASE
WHEN age = 56 THEN 'ccc', 'ddd'
WHEN age = 78 THEN 'eee', 'fff'
ELSE first_name, last_name
END
-----------------------------------------------Can you give an example of a nested decode statement.
test@ora>
test@ora>
test@ora> --
test@ora> drop table t;
Table dropped.
test@ora> create table t as
2 select rownum x, cast(null as varchar2(10)) y from all_objects
3 where rownum <= 10;
Table created.
test@ora>
test@ora> select x, y from t;
X Y
1
2
3
4
5
6
7
8
9
10
10 rows selected.
test@ora>
test@ora> -- You want to change the values of y to 'a' through 'j' for x = 1 through 10
test@ora> -- and y = 'X' otherwise
test@ora> --
test@ora> -- Let's say the limit on the number of components were 12
test@ora> -- Then your decode statement would've been:
test@ora> --
test@ora> update t
2 set y = decode(x,
3 1, 'a',
4 2, 'b',
5 3, 'c',
6 4, 'd',
7 5, 'e',
8 'f');
10 rows updated.
test@ora>
test@ora>
test@ora> select x, y from t;
X Y
1 a
2 b
3 c
4 d
5 e
6 f
7 f
8 f
9 f
10 f
10 rows selected.
test@ora>
test@ora> -- As you can see you are unable to:
test@ora> --
test@ora> -- change y to 'g' if x = 7
test@ora> -- change y to 'h' if x = 8
test@ora> -- change y to 'i' if x = 9
test@ora> -- change y to 'j' if x = 10
test@ora> -- change y to 'X' otherwise
test@ora> --
test@ora>
test@ora> -- What you would do then is -
test@ora> -- (i) Let the 11 components remain as they are and
test@ora> -- (ii) Introduce a nested decode function *AS THE 12TH COMPONENT*
test@ora> --
test@ora>
test@ora> rollback;
Rollback complete.
test@ora>
test@ora> --
test@ora> update t
2 set y = decode(x,
3 1, 'a',
4 2, 'b',
5 3, 'c',
6 4, 'd',
7 5, 'e',
8 decode(x,
9 6, 'f',
10 7, 'g',
11 8, 'h',
12 9, 'i',
13 10, 'j',
14 'X')
15 );
10 rows updated.
test@ora>
test@ora> select x, y from t;
X Y
1 a
2 b
3 c
4 d
5 e
6 f
7 g
8 h
9 i
10 j
10 rows selected.
test@ora>
test@ora>HTH
isotope
Extrapolate that to 255 components and you get 254 + 255 = 509 components. And so on...
Message was edited by:
isotope -
Updating a blob column using a ResultSet
Hi,
I'm using jdeveloper 3.2.3 with a 9i database and the smartupload component to save file in a blob column.
I'm using the following code
String sSql0 = "SELECT DOCUMENT.NEXTVAL FROM DUAL";
oracle.jbo.html.jsp.JSPApplicationRegistry appRegistry = oracle.jbo.html.jsp.JSPApplicationRegistry.getInstance();
appRegistry.registerApplicationFromPropertyFile(session,"dgpa_bd_BdModule");
ApplicationModule am = appRegistry.getAppModuleInstance("dgpa_bd_BdModule",request,session);
ApplicationModuleImpl appMod = (ApplicationModuleImpl)am;
PreparedStatement stmt1 = appMod.getDBTransaction().createPreparedStatement(sSql0, 1);
String sSql2 = "SELECT t.* FROM TGTDOCD0 t WHERE IDOCUMEN = 32";
Statement stmt2 = stmt1.getConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY ,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt2.executeQuery(sSql2);
if (rs.next()) {
// Initialization
mySmartUpload.initialize(pageContext);
// Upload
mySmartUpload.upload();
// Add the current file in the DB field
mySmartUpload.getFiles().getFile(0).fileToField(rs,"gdocumen"); //gdocumen is the blob column
// Update
rs.updateRow();
rs.close();
stmt2.close();
But when i run the rs.updateRow() i have the follwing error: java.sql.SQLException: ORA-01008
what's i'm doing wrong?
Thanks
RJCWhere is the image coming from? Are you getting it from a file? User Upload?
Here is an example using a procedure in Oracle to upload a file to a blob..: http://technologydribble.info/index.php/category/load-file-into-blob/
Thank you,
Tony Miller
Webster, TX
You know, um…I used to think that it was awful that life was so unfair. Then I thought, wouldn't it be much worse if life were fair, and all the terrible things that happen to us come because we actually deserve them? So, now I take great comfort in the general hostility and unfairness of the universe
Anla-shok Marcus from Babylon 5 -
Updating Workflow status/intructions
We are interested in updating the instructions for several steps in our workflows without having to inactivate steps and create new. We don't need to maintain what will be the archived record of the old status and just want to update the instructions everywhere. Is there a way to do this?
Hi Melissa,
The workflow step names and instructions can be found in the commonWorkflowStatus table.
To find the status names and instructions for a specific workflow template, you can run the following query:
select temp.pkid, tempml.Name, tempml.Description, steps.Position, stat.*
from gsmWorkflowProcessTemplates temp
inner join comLWFProcessTemplateML tempml on temp.pkid = tempml.fkLinearWFProcessTemplate
inner join gsmWorkflowActivityTemplates steps on steps.fkProcessTemplate = temp.pkid
inner join commonWorkflowStatus stat on stat.pkid = steps.fkWorkflowStatus
where tempml.Name like '%YOUR_WORKFLOW_NAME%'
order by tempml.Name, steps.Position;
Note that when you update the commonWorkflowStatus table, each entry is language specific, so if there are duplicate pkids, they have different language IDs. Your update statements should specify the langID if you have multiple languages for the status you want to change.
You'll probably want to schedule a cache flush event after making these updates.
Regards,
Ron
Maybe you are looking for
-
Why do I have such poor/sporatic signal strength?
I have an iBook G4, and ever since I bought it i have had trouble with wireless connections. In my home, a small one bedroom apartment, I have and airport station. Connected to this is an external antenne. This is hooked up to a PC. My laptop has an
-
How to set a line of table as read only during runtime?
How to set a line (or a cell) of table as read only during runtime?
-
I'm thinking of upgrading to the studio version just to get Sculpture. But from what I hear Sculpture is CPU hungry. So how does Logic perform if there are multiple Structure tracks in a project? Does it crash or get really slow?
-
BPS External Hierarchy with Postible Nodes
Hi, I am using External Hierachy (more than 2 levels) in BW and Characteristic relationship between Account and Account Group in BPS. Account group is an attribute on Account. I have included the Account Group in the Planning Level. On the layout Acc
-
Where in Ireland can i get a replacement right arrow (end) key
i have a macbook and my end key (wwhich was always crooked snapped in half while i was playing marbleblast yesterday, where can i get a replacement for it