How to update a listitems say status column in my document library from Pending to Approved without using event receivers or C#?

If I use SPServices , it needs to be added as content editor web part code / separate js function in master page.

My issue is, I can't use this approach as I am creating sub sites/doc libs automatically on a button click event of my visual web part.

Here, end user will use the default UI form for updating the list items.

Any other approaches available?

  • when you want your Status column to change from Pending to Approved? Do you want this update on your site/library creation? – Zakir HC Mar 15 '16 at 9:20
  • No. when end user adds an item into the document library, i need to update the column value to pending with approver1 and when approver1 approved, i want to changed to approved by approver1 ...am not using sp d 2013 WF manager . am tryng to find out a non-managed/ non-c# , non-wsp solution – userAZLogicApps Mar 15 '16 at 9:27
  • What do you mean by SPD 2013 WF manager? It should be either SPD 2013 workflow or SP 2013 WF manager. SPD 2013 WF is your no-code logic with rules and conditions whereas SP 2013 WF Manager is the new workflow management. – Zakir HC Mar 15 '16 at 9:44
  • My mistake, i mean to say SP 2013 WF Manager. – userAZLogicApps Mar 15 '16 at 9:52

If you can not load JS code in the (Master)Page, JSLink, or Custom Actions...

Then place the code inside the ListItem with JavaScript in a Calculated Column,

Here are some examples to get you started: http://viewmaster365.com/#/Create/

I adapted one of the top of my head, have NOT tested it

in a View (and a View only!) this Calculated Column Formula will display a Button for each ListItem

="<button onclick=""{event.stopPropagation();"
 & "    var context=new SP.ClientContext.get_current();"
 & "    var list=context.get_web().get_lists().getById(SP.ListOperation.Selection.getSelectedList());"
 & "    var item=list.getItemById( GetAncestor(this,'TR').id.split(',')[1] );"
 & "    context.load(item);"
 & "    item.set_item('Status', 'Approved');"
 & "    item.update();"
 & "    context.executeQueryAsync("
 & "     Function.createDelegate(this, function(){"
 & "        AJAXRefreshView({currentCtx:ctx,csrAjaxRefresh:true},1);"
 & "     }));"
 & "    }"">Approve</button>"

Disclaimer: It is a PITA to debug Calculated Columns. Because you don't get feedback until you save a Formula (with an undescriptive message) and you end up having to click multiple times to get back to your Formula.

I have written a small 'CalcMaster' bookmarklet which hooks into the formula-editor and does a save of the Formula on every keypress; giving immediate feedback.



You can achieve this by creating a simple SharePoint Designer 2013 Workflow and a custom column "Status".

  • First enable Content Approval in your document library through Library Settings > Versioning Settings. Detail steps given in this ARTICLE.

  • Create a custom choice column Status and provide two values - Pending and Approved. Make Pending as the default value. This will meet your need when a user adds a document to library the Status column value will be updated as Pending automatically.

  • Open SPD 2013 and create a list workflow on your document library.

  • Just insert below two steps and you are done. Save and publish the workflow. Ensure you select "Start workflow when an item is changed" at the Start Options.

The workflow checks if the document is approved via Content Approval and if it is approved then your Status column value is changed to Approved.

enter image description here

  • you have told, create a list workflow.By default, its a sp 2010approval 2010 workflow will be selected?So in this case, when i tried with am not getting the result as you mentioned. – userAZLogicApps Mar 15 '16 at 14:33
  • There is an out of the box approval workflow and there is another SharePoint designer workflow. You must open your SharePoint Designer and create a list workflow and associate it to your document library. Check this plexhosted.com/billing/knowledgebase/227/…, it should guide you on creating a list workflow. – Zakir HC Mar 16 '16 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.