What's the best way to place a time constraint on a catalog item?

patricklatella
Mega Sage

I need to place a time constraint on a catalog item.   For example, the item is available upon approved request, but only for a 10 day period...what's the best way to apply this constraint?

1 ACCEPTED SOLUTION

You do not need a script include to make sure that the end date is not before the start date, only the lines I added - checked and verified in my instance.


If you have all the script I provided, you should be covered.


Please make sure you added the lines to the correct script.


Also, reload the catalog item page after adding and the lines and saving the script.


If it still does not work, please share your script with the lines included.



harel


View solution in original post

41 REPLIES 41

hmmm, something strange happening now...when I enter "Go To Today", or manually enter today's date in the start field on the catalog item's order form, I'm getting the error we built to prevent entering a date before today's date.   Did I inadvertently mess something up?   I swear it was working...some kind of internal time zone difference in the system?   It works fine if I enter tomorrow, just not today all of a sudden.  


is it because the system (or this function) is set up on a 9-5 time schedule and so it thinks today is done because the work day is done?


and also just to clarify, although a single user is now restricted from making a request for one of these catalog items for overlapping time periods, other users should be able to make requests for the same catalog item for the same time period as someone else...in other words the time frame constriction should not be on the item itself, (more than one user can request the same item at the same time).   No user should be able to request more than one of these catalog items for an overlapping time frame.   Does this make sense and should your code do that?   It appears to be locking out other users from requesting the same catalog item as someone else if there is already an existing request for the same catalog item for the same time period.   Sorry if it's confusing.


About the error - which one are you getting? might need to tweak the code a bit.


About the multiple users - you are correct.


In the last script include, please change the line


open.addQuery('requested_for', user);


to


open.addQuery('request.requested_for', user);


This is because the requested_for field is actually a part of the request table, so we have to dot walk.


Try again and let me know.



Harel


When impersonating a user who has not yet requested any of these new catalog items, I'm getting the error that they have overlapping requests, even thought it's their first request.   Now I do have open requests by other users, but that shouldn't matter.   I'll change the code and see if it works.   I'm also building a workflow for the delivery of these catalog items, is there any way that could mess up the functionality of the catalog client scripts?