Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, April 17, 2013 3:07 PM
Hello,
I am using Sharepoint 2010 and for one of my Lists, I am using a general list workflow. What I need to be able to do is determine if a column value has change (say an "Assigned To" field) because I only want to take some action if that particular value has changed. I want to be able to have a workflow action that would be something like:
If Current Item: Assigned To not equals [OLD VALUE]
I have found some web searches that talk about creating a duplicate list or duplicate (but hidden) column but that doesn't seem to be the way to go. I have document versioning set but don't if that can be used to help with this. One possible thought (although I haven't tried it to see if it works) is to create local variables and have the values in the variables be the "old value". Just not sure if there is a best practices for doing this.
Thanks for any thoughts - Peter
All replies (10)
Wednesday, April 17, 2013 5:43 PM âś…Answered | 2 votes
This is not possible directly because, workflow is executed when list item is updated in database. So if you need to get last value store in AssignedTo field.
You need to make some design change to get this functionality,
1. Create a Column AssignedTo_PreviousState.
2. Modify workflow to Check like below
If Current Item: Assigned To not equals CurrentItem:AssignedTo_PreviousState
put your logic.
If this helps Please mark it answer or Vote As Helpful.
Thanks
Siddharth Vaghasia
Wednesday, April 17, 2013 6:08 PM | 1 vote
Siddharth,
Thanks for the reply. Yes, I found out that the local variables do not carry over to the next insatnce of the workflow (ie. subsequent form updates). I eventually found a nice short article on how to create a hidden column:
http://www.mssharepointtips.com/tip.asp?id=1002
This would be where you create the AssignedTo_PreviousState column and then make it hidden. Then, as you suggest, use that field to pass old values on each update given that you update the field value in the workflow actions. The only other thing that I had to figure out was how to hide that column in the views as well. Now I seem to be good.
Thanks again - Peter
Thursday, October 31, 2013 8:47 PM
Hello,
I'm trying to accomplish the same thing - How do you pass the old values to the hidden field?
thanks,
Helen
Friday, November 1, 2013 12:16 PM
Helen,
So what I ended on doing this this type of scenario is the following:
1) Create a new column for the list that will be used as the hidden field. I initially hid the field on my custom forms through the solution listed in the article http://www.mssharepointtips.com/tip.asp?id=1002, but then I would just create a column and then in our custom forms I would just update the HTML code to give that column's table row a hidden style.
2) In our workflow, I would then set my hidden column value to the value of the other corresponding visible field (at the end of the workflow). Somewhere earlier in the workflow I would compare the hidden column's value with the visible column's value. If they were different, then I knew the user changed that value and did something. So the wokflow would look something like:
STEP 1:
if Current Item:hiddenStatus not equals Current Item:Status
....... [ do whatever]
Step 2:
Set Current Item:hiddenStatus to Current Item:Status
The next time the form is saved and the workflow is called, the hiddenStatus column will contain the value of the Status column the last time the form was saved.
I hope this is what you were asking about. If not, please let me know.
- Peter
Friday, November 1, 2013 1:10 PM
Hi Peter,
Thank you for your reply - that did work! One more question. Do you know of a way to loop this step? I am creating a task list which I would like for people to be able to communicate through the comments section if necessary. So I would like the workflow to keep checking that condition (If Current Item:Comments not equals Current Item: Comments PreviousState) to send an email UNTIL Another condition (Status equals Complete) is met.
I'm very new to SharePoint, so I'm not entirely certain what the possibilities are.
Thanks again for your help,
Helen
Friday, November 1, 2013 2:20 PM
Helen,
Not sure I fully understand your goal. We don't use "tasks" at all but if you are looking to have your workflow check certain valus and be able to send email messages to people based on whatever, then you can certainly do that (as long as your Sharepoint has the email setup. We do this for alot of workflow tasks.
So, in the workflow you can have a blanket statement like what I previously listed:
if Current Item:hiddenStatus not equals Current Item:Status
.... do something
or you can do something like:
if Current Item:hiddenStatus equals "In-Progress"
.... do something
Else if Current Item:hiddenStatus equals "Completed"
.... do something
or combine the two and do nested "if" statements. Then you add an email statement wherever you need it like:
if Current Item:hiddenStatus equals "Completed"
then email "these users"
To add the email part, just type in "email" on the line where you want to add a statment. There is only one option to choose from. That will display the line "then email these users". The "these users" will be a link. When you click it you will get a popup to add the email info. We typically will send the email to a user (or users) that are already listed in one of the PeoplePicker fields. On the email form, you can type in your own text, designate that a value is based on a column value (like our PeoplePicker), designate that a value is based on a workflow variable, add a link to the current item, etc. To get to these options you will click the button to the right of the fields or use the "Add or Change Lookup" button in the bottom-left for the text area. There is alot you can set in the mail.
Does this help answer your question?
- Peter
Tuesday, June 17, 2014 7:13 PM
Hi Peter-
So I want to take a different but similar path. I want just mark the field that has been edited with the word "EDITED" next it so that the user knows which field has been edited. Very similar to how in Sharepoint 2010 with the alerts function it told you what fields were edited simply by labeling the field with "EDITED". Do you know if this is possible?
-Adam
Tuesday, February 3, 2015 1:46 AM
Hi Peter,
I tried doing this, for a column that is a standard Sharepoint 2013 "People or Group" column, and it isn't functioning properly. Do you know any tricks for those column types? It's the type of thing where I can type a first name into a list and it'll look up option against the company data base. Unfortunately I've also tried an intermediary step where I store the value in a local variable, and it still isn't working. Not only is the email not sending, but the secondary column is not being updated. I've tried, and can make a normal email workflow function properly.
PS the goal is to see if the person in the "assigned to" field has changed, and if so, e-mail the new "assigned to" person a note advising that they have recently been assigned to a SharePoint document library item.
Thanks!
Lydia
Friday, April 15, 2016 3:09 PM
Thank you for the answer. The workaround you suggested is easy to implement.
However, the reasoning you provided is not logical. If workflow was executed when list item is updated, it should be possible to access previous value when database is updated, because db trigger can access the previous value.
I suspect that workflow executes after the update. This is more likely why previous value is not accessible.
Thursday, January 5, 2017 6:24 PM
Hello Peter,
Your answer really helped me. Here is my SPD workflow -
Regards,
Sam