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

Sorry I needed to fix the typo in 2 places...had only fixed one of the typos the first time...it works...perfect!   Thanks so much Harel!   Now is it possible to have these catalog client scripts and script includes cover a number of specific catalog items?   Or do I need to recreate catalog client scripts specifically assigned to individual catalog items?


What I'd do is create variable sets instead of individual fields (variables). Put the onChange scripts I provided in the variable set.


For instance, the script I gave to check that the day entered is not in the past (nowDateCalc) runs on a variable set called date_needed_by which I placed in several catalog items. So I don't need the same script in each if the items, but only once.


This is the variable set:


find_real_file.png



This is the client script in the variable set:


find_real_file.png



harel


awesome Harel, thanks again!


another question if you're up for it...I am creating a workflow for the approval of these requested catalog items and need to have the requests be approved by the manager of whomever is ordering.   I'm creating my workflow and I've generated a "Manager's Approval" workflow activity.   I'm seeing that I can put in a script in the "Advanced" section so that the request for approval goes to the manager of whomever is ordering, but I can't find the script.   Is a script you know?   And as well is there a list or database of commonly used scripts?  


You do not need a script. You can dot walk the user's manager:


find_real_file.png


In other situations you can write a simple script.


Example: My requested items have a custom "approval" field where I specify what kind of approval the items needs. If the approval is only of the manager, my script will look like this:


answer = [];


if(current.cat_item.u_approval == 'Manager')


  answer.push(current.request.requested_for.manager.sys_id);



The script does what the above screenshot does...


harel