3

I have 2 list:

Stockinformation (location, product, amount)
Stockrequest (location, product, status, department).

(there are more list, but they are lookup list for e.g. locations and product)

What I want to do here is that when someone request product x from location y, and the status is e.g 3 (processed), that the stock in the stocklist gets updated (reduced).

I created a workflow on the request list and set 2 variables (set location and set product). Now I want in the stock list a workflow that says:

If location = variable location
 and product = variable product

Then "amount" - 1

Could someone put me in the right direction to solve this matter?

2 Answers 2

3

This is a little tricky since you're using two fields to identify the row that needs to be updated. If you were simply updating the stockinfo list based on one field, such as the product name, that would be simple. You'd just retrieve the current value, subtract one, and update the list with the new value. However, the "update item" in SPD workflows only allows you to use one field to determine which row will be updated. To get around this:

  1. create a new field in stock info called "stockinfoid"
  2. create a workflow on new and update for the stockinfolist that sets stockinfoid to a concatenation of product and location. Now you have a unique id that will be updated every time you add or edit a row in the info table
  3. In the workflow, create a variable called calcStockInfoId, and set it to be the values of the product and location from the current row. Now you have the unique ID from the current row, that should match one of the values in the stockinfoid field of the info list
  4. create a variable to store the current quantity
  5. use the set workflow variable action to get the current quantity. You'll be retrieving the value from the stock info list, where stockinfoid = calcStockInfoId
  6. use the calculate action to subtract one from the current quantity
  7. use the the update item action to set the value of the quanity, again using the stockinfoid field and the workflowvariable to update the right row.

edit: it's tempting to set up a calculated field for the first part. That works in theory, but calculated fields aren't supported in the workflow filters, so go with the secondary workflow.

2
  • Thank you Mike, I got started. I have now a workflow that sets the stockinfoid, and adjust the stock by -1 when the item changes. Except, I only want it to adjust when in an other form (list) the field "status" is equal to "processed". I wanted to create a new stockidinfo in that list that is product + location, except I can only get location ID (it's a filtered lookup) so that's not easy. Any Idea? I think you only work with 1 list right?
    – Ramon Luth
    May 2, 2017 at 12:10
  • steps 1 and 2 are for the stockinfo list, 3 - 7 are in the workflow for the stockrequest list. So the amount in stockinfo will be modified based on a change in stockrequest. If you need to take status into account, just put the steps in an if statement so that they only run for the appropriate status.
    – Mike2500
    May 2, 2017 at 15:19
3

I did this in my opinion , but if you change the field and variable, it will help you.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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