Friday, June 14, 2019

Display Specific Message on Web Store Based on a Custom Defined Day

This article describes how to show a specific message on the web store duringholidays and other custom defined days.

This solution takes advantage of existing HTML fields on web site tabs andJavaScript code.

  1. Setup > Site Builder > Set Up Web Site 
  2. Click Edit on preferred Web Site
  3. Switch to Appearance sub tab, at bottom of the page select tab where user want to show customer-facing message. (Other tabs can be defined at Lists > Web Site > Tabs)
  4. Edit the Web Site Tab
  5. Switch Message field to Source Edit mode.
  6. Paste the following sample code:
<script type="text/javascript">function in_array(needle, haystack) {    for(var i in haystack) {        if(haystack[i] == needle) return true;    }    return false;} var holidays = new Array();holidays.push('1/1');holidays.push('24/12'); var currentDate = new Date();var day = currentDate.getDate();var month = currentDate.getMonth() + 1;var holiday = day + '/' + month; var isWeekend = (day == 6) || (day == 0 || in_array(holiday, holidays)); if (isWeekend) {	document.write('Your SO will be processed next business day.');} else {	document.write('Welcome! There is currently no holiday');}</script> 

Note:If user switch back "formatted text" mode, there will be no content, but theJavaScript code will be still stored. Please keep it in mind when editing thefield in the future.

Now when the web site is opened, the specific message will be shown dependingon today's date.

Disclaimer: The sample code described herein is provided on an"as is" basis, without warranty of any kind, to the fullest extentpermitted by law. NetSuite Inc. does not warrant or guarantee the individualsuccess developers may have in implementing the sample code on theirdevelopment platforms or in using their own Web server configurations.

NetSuite Inc.does not warrant, guarantee or make any representations regarding the use,results of use, accuracy, timeliness or completeness of any data or informationrelating to the sample code. NetSuite Inc. disclaims all warranties, express orimplied, and in particular, disclaims all warranties of merchantability,fitness for a particular purpose, and warranties related to the code, or anyservice or software related thereto.

NetSuite Inc. shall not be liablefor any direct, indirect or consequential damages or costs of any type arisingout of any action taken by you or others related to the sample code.


No comments:

Post a Comment