AnsweredAssumed Answered

Change Lending Library starter solution Process Check Out script to accommodate a Quantity field

Question asked by JamesClark on Jan 12, 2011
Latest reply on Jan 14, 2011 by philmodjunk

Title

Change Lending Library starter solution Process Check Out script to accommodate a Quantity field

Post

In the ProcessCheckOut script, in the History section of the Scripts in the Lending Library starter solution I'm trying to adjust it so that when someone presses the 'check out' button on a record in the Assets layout, the script performed will only change the AssetId status to 'not available' if the value of the field 'Quantity' is less than or equal to 0. I added the quantity field to the Assets and History table and modified the script so that upon executing the ProcessCheckOut script, when the other values already in the script are committed to a new history record, so too would the value of the Quantity field I created in the History::Quantity field. 

As I understood it and how I intended this to work was that a user specifies the quantity of an item they want to borrow from the Item's record which updates the value of the quantity field. This value is then committed to the history::quantity field from the assets:quantity field and the part of the ProcessCheckOut script which originally said set field [Assets AssetId::status; "Not Available"] is now part of an if condition which evaluates whether or not the Assets::Quantity field is less than or equal to 0. If it is, then the asset is not available otherwise it should remain available.

the script appears to still execute just fine, but it's just ignoring my changes, an item is considered checked out if the check out button is pressed in the Assets layout and the quantity of that item available appears to have no bearing on this, if I check out 2 of an item of which there is a quantity of 5 leaving 3 remaining for lending: attempting to borrow any of the remaining 3 simply results in the message "this item is already checked out" appearing. I don't know where I've gone wrong.

If it's not immediately apparent, I'm not a programmer and I'm just trying to follow the logic of the scripting as best I can. Please forgive any grievous errors I've apparently made, it comes from my naivety.

Outcomes