Set (content) approval status in workflow [Sharepoint 2013] - sharepoint

I have a custom list with approved and not-approved items.
Now I created a workflow that changes the value of one of the fields.
Problem is: After running that workflow, the Approval Status of this item is automatically set to "Pending". But I don't want to change this status.
I tried to switch on/off the checkbox "Automatically update the workflow status to the current stage name" but no effect.
I also tried to set the variable inside the work flow:
Set Variable: ApprovStatus to CurrentElement:Approval Status
then Update item in CurrentElement
then Set Workflow Status to Variable: ApprovStatus
Go to End of Workflow
How can I keep the current Approval Status (or set it to the value that it was before)?
When a item is (manually) approved, will it also work then?

I got it!
Solution was to use a Sharepoint 2010 workflow instead of 2013:
Set Variable: AprSt to Current Element:Approval Status
Update item in Current Element
If Variable: AprSt not equals 0;#Approved
Set content approval status to Pending with comments
Else
Set content approval status to Approved with comments
Now it works.

Related

SharePoint document approval workflow, modified and approved by fields

I working on a SharePoint document approval process and here is the scenario: A document is uploaded in the document library, and approval process is initiated. A task is created and assigned to a group (Active directory group) where only one group member can complete the task. What is required is the modified by and approved by fields to display the name of the user who completed the task and not the group name that the task is assigned to.
1) I have tried the out of the box workflow, and if displays system account as the user who completed the task.
2) I have tried SPD approval workflow, and it displays the group name assigned to.
3) I have tried VS sequential workflow :
With VS workflow, I’m able to set the correct user to the two fields (modified by and approved by) and as the last step I need to set the approval content status as follows:
item.ModerationInformation.Status = SPModerationStatusType.Approved; (if approved)
But this runs with system account permission and not the current user, so it resets the field approved by back to system account, and if I swap the sequence of my steps and set the content status first then update the fields last, obviously I’m doing a modification on the item so the content status changes back to draft.
Is there a way I can run this item.ModerationInformation.Status = SPModerationStatusType.Approved; under the current user? Or any way I can achieve my goal?
I would suggest leaving the system columns alone and creating a completely different set of columns for your purposes.
So Create the columns: "Item Modified By", "Item Approved By"
Then write the current user to these fields.
Lastly, remove the system generated "Modified By" and "Approved By" from the default view and replace them with your "Item Modified By" and "Item Approved By" columns.

SharePoint Issue Tracker - auto approve if in a group and auto set of 'source'?

SharePoint 2007
I've setup and Issue Tracker as a quick ticket system. I gave everyone in all the internal domains access to view the page and to create items, then I made a list of team members and gave them rights to edit/delete items (etc).
The Issues all have a "pending/approved" column and a radio button selection on the new issue form to choose between "internal" or "external" issue (if a core team member created the issue or someone from the outside).
I'm not sure if it's possible but I've been trying to figure out how auto set the internal/external radio selection (if the person creating the issue is on the list of core team members - auto set 'source' to 'internal' else 'external'. And I've also been trying to figure out how to auto-approve items if they are internal items.
So, if someone on the team member group list creates an issue it should be automatically have it's source set to "internal" and it should be auto-appoved.
Thanks for any help!
One solution would be to use SharePoint Designer like this:
Customize the NewForm.aspx to remove the internal/external field altogether from the initial creation.
Create a new workflow on the list that automatically starts when a new item is created.
Use the condition "Created by a specific person" and choose the created by to be the Team Members group
Set the action to "Update List Item" and set the Internal/External field to internal
Add an additional action of "Set Content Approval Status" and set it to Approved
Click the "Add 'Else If' Conditional Branch" link
Add an action for the Else condition of "Update List Item" and set the Internal/External field to external
The first step is just for appearance (since regardless of what they choose you will be setting it for them automatically). The workflow will take care of auto setting your fields based on the creator's group membership.
You need an event receiver that fires on ItemAdded (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.aspx) that sets both Source depending on the user that posted the issue and approves if source is internal.

sharepoint 2007 workflow trigger

I have an initial workflow in Sharepoint Designer that triggers whenever an item is created and also whenever an item has changed in the 'Employee' list .
Within second workflow I am updating the 'Employee' list and the workflow above is triggered.
Is there any way I can check in the intial workflow if the item has been updated by a user or if it was updated by a workflow. In the case if the item was updated by a workflow I would not want to trgigger it.
Many Thanks,
Through SharePoint Designer, you cannot cause an update to an item to not trigger workflows that are listening for it. But, you can cause the workflow to basically be skipped with one extra Step.
Try checking out this article at Microsoft Office, which discusses secondary workflow interactions in SharePoint Designer. In the first step, it identifies whether an item was created by a specific workflow, and cancels the workflow if it isn't. We just need to adapt this - if we successfully identify the item as being modified by your secondary workflow, then we want to cut off the first workflow.
You need to create a new Step in your initial workflow, and move it to the top. In it, choose the Compare Tasks Condition. In that condition, set field to be "Workflow Name", leave the operation as "equals", and set value to be the name of your secondary workflow. Then, add a Stop Workflow Action, specifying some appropriate workflow history message to indicate that the workflow was triggered by the secondary workflow so it was terminated.

Block SharePoint workflow from running unless prerequisites are met

I've got a scenario where I want a workflow to not run if a certain condition is true, otherwise to run when a list item is created. The scenario is for a people management system. If a new list item (staff member) is added to the list then the workflows job is to go between the various departments and get everthing setup. Eg payroll, IT account ect. One of the fields is Start Date that may or may not be entered. If it is entered then I don't want the workflow to run when the item is created. I want the policy on the list to start the workflow on that date. I can add some code into the workflow to end itself if the date is in the future but then this will show as completed on the list. This is a problem because the workflow shouldn't show that it's run as in effect it's waiting for the date to be correct.
In other words, is there something in onWorkflowActivated that allows me to stop the workflow from triggering so that nothing shows up in the site, in essence to suppress the workflow from running as if it was never triggered by the OnCreated event.
Can you add a new step at the beginning of the workflow to fill in the Start Date? I think this makes sense in terms of your workflow because the HR person has an action item on their plate: enter the start date.
Otherwise you could make Start Date a required field on the sharepoint list.
This is SharePoint Designer version, see if you can use the same activities in VS
Create a second workflow that executes the rules after StartDate is set
In the main workflow, create a step with the action 'Wait for Field Change in Current Item' and config it to 'StartDate not Empty'.
The next action will be a 'Start Workflow', executing the second Workflow you created.
You also have a Stop Workflow activity

Sharepoint Designer - Creating a simple Workflow, check status of another Workflow

I'm trying to create a simple workflow using the Sharepoint Designer. We already have one user-defined workflow, called Internal Approval. This creates a column with the same name.
Basically, my workflow should perform:
Conditions:
if Internal Approval equals Approved
and Status equals Draft //custom field I want to set, this works
The problem, after a quick debug, is that the Internal Approval does not equal to Approved nor contains it, Internal Approval equals 16.
The question: what is this number, and can I rely on it always being 16 for an approved workflow?
Or better, how can I check a if another workflow was approved?
May be this could help you Workflow Status
Reference Article from MSDN, just type case the above Enum to Integer you will get the values.
Also to filter based on the Workflow Status in the View. Refer

Resources