remove option not working on catalog client script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2023 02:54 PM
I am trying to use same client script which is working on the desktop/platform . I am trying to remove options based on date range . For example : I have a request type with 5 options and I have requirement where I have to show only 2 choices under request type from November - March . I tried onload client script for desktop where I passed date range as json and used gs_form.removeOption(‘request_type’, ,’bonus_form’);
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2023 06:49 AM
function onLoad() {
var requestType = g_form.getValue('request_type');
var dateRanges = {
"annual_bonuses": {
"start": "2024-02-01",
"end": "2024-02-28"
},
};
processRequestTypes(dateRanges);
function isRequestTypeVisible(requestTypeValue, dateRanges) {
var currentDate = new Date();
if (dateRanges.hasOwnProperty(requestTypeValue)) {
var startDate = new Date(dateRanges[requestTypeValue].start);
var endDate = new Date(dateRanges[requestTypeValue].end);
return currentDate >= startDate && currentDate <= endDate;
}
return false;
}
function processRequestTypes(dateRanges) {
for (var keyID in dateRanges) {
if (dateRanges.hasOwnProperty(keyID)) {
if (!isRequestTypeVisible(keyID, dateRanges)) {
switch (keyID) {
case 'annual_bonuses':
g_form.removeOption('request_type', 'annual_bonuses');
break;
}
}
}
}
// Show choices based on the specified timings and date ranges
}
}