Is it possible to calculate and update value in another workspace

Is it possible to calculate and update value in another workspace

Anonymous
Not applicable
972 Views
2 Replies
Message 1 of 3

Is it possible to calculate and update value in another workspace

Anonymous
Not applicable

Hi,

 

I had an Inventory workspace with records of all available parts. Then I had another Request workspace where users will raise a request to draw out any part that they might need and this request will have to go through a workflow where a selected approver will approved the request before the user can withdraw the part from the store.

 

In the raise request, when user select the part from a picklist created using the Inventory workspace, the Quantity field as a derive field will display the 'Live' value from the Inventory workspace in the request to enable user to check on how many pieces are currently available. User will fill the Required Quantity field with the amount part they need into the request which will be sent to approver to approved. 

 

My question: Is there a way that when the approver approved the request, the Quantity (in the Inventory workspace) can be updated with the new value after deducting the Required Quantity? My guess is, probably an action script placed in the approve transition might do the job,however, is there an example how the script will look like? Any similar examples would be good for me to kick start.

 

Really appreciate any suggestions or examples provided.

Thank you in advance for all the help.

 

Best regards,

Carol Mak

 

 

 

 

 

0 Likes
Accepted solutions (1)
973 Views
2 Replies
Replies (2)
Message 2 of 3

jared.sund
Alumni
Alumni
Accepted solution

 

Hello Carol, 

 

You are correct, a simple action script can be used to update the quantity in your inventory item from your request item.   In PLM 360 scripting, picklists based on a list of workspace items allows you to link directly to the selected item in the picklist.  The script example below represents an action script that could be tied to the request item's final approval workflow action (transition).  In this case "item" represents the request workspace item, and INVENTORY_PART represents the field ID of the picklist.

 

So, item.INVENTORY_PART is the item selected in the request's picklist.  Therefore, you can read and write to the picklist linked item's fields (in this case INVENTORY_QTY).  

 


//update the related picklists item's qty.
item.INVENTORY_PART.INVENTORY_QTY = item.INVENTORY_PART.INVENTORY_QTY - item.REQUESTED_INVENTORY;

 

Example validation script to ensure that the requested inventory quantity does not exceed the actual inventory available.

 

//Array used for storing any user messages that will be presented to the user
var messages = [];


if((item.INVENTORY_PART.INVENTORY_QTY - item.REQUESTED_INVENTORY) < 0){
  messages.push("Requested Inventory is greater than what's currently available, please update");
} //return the messages array, empty or populated returnValue(messages);

 

Hope this is helpful, 

 

-Jared

Jared Sund
Sr. Product Line Manager, Product Lifecycle Management
Autodesk, Inc.
Message 3 of 3

Anonymous
Not applicable

Hi Jared,

 

Perfect solution! The examples work perfectly.

Many thanks to all the help!

 

 

Best regards,

Carol

0 Likes