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

I think that change in the script include did the trick...testing now.   Regarding my workflow, I've inserted as the first step an "Approval Request" by the manager as we discussed earlier in the thread...but when I submit a test request it is automatically approved...am I missing a step or something to make it so the manager has to approve the request for it to move forward.   And also, if in impersonate the manager of a user who has submitted a request, should I be able to see the request somewhere in their world?


well no actually I'm still seeing inconsistencies where a user can request items with overlapping time frames.   Let me do a full double check through all the codes at this point, maybe I'm getting them jumbled up.   I really thought this was working before but something seems to have gone off a bit.



So we should have:



3 clients scripts:   all of which run "onChange", 1 of which is on the start_date and 2 are on the end_date.  


3 script includes: NowDateCalc, calcDate, and checkOLDates


As well the only function that seems to be not working is this overlapping dates of the requests.   The "Go To Today" date issue from earlier has gone away now that it's the next day.   So yes, only this overlapping date thing left to fix.   again, let me double check...so there should be one catalog client script and one script include for governing the overlapping date issue...correct?


Yes, only one catalog client script and one script include for the overlap.


Make sure that the variables in the script include match your variables: open.variables.<start and end dates field names>


In the client script:


1. Make sure for the same in the client script. Sometimes a typo or a mistake in the field's name can cause weird and interesting issues.


2. Make sure that the variable name you are running your script on is correct (I have it set as end_date)



harel


double checking the field names now, pretty sure I have it correct.   I'm just copying and pasting your code, and I have the variables name end_date and start_date.   So right now it is only enforcing the overlapping date restrictions per user (which is correct), but also only per catalog item (incorrect).   I have several catalog items sharing the end_date and start_date variables in a variable set, and 1 separate catalog item which just has the variables individually listed.   (all of these catalog items are part of this same group of catalog items I need these restrictions to apply to).