Important Update to Custom Scripting
SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!
Legacy Custom Scripting Language Deprecation Plans
- New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
- As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
- In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.
Ever want to use a future or past date dynamically in a survey? We have just the workaround for you! In this tutorial we will cover adding or subtracting time to/from the current date.
Check it out in an example survey
Add a survey with this setup to your account!
This workaround is great for most of our customers but may require some tweaking to get it right. If you have a solution that works better please let us know!
This script uses the following question types or actions:
- Hidden Value to Store Date for Later Use
- Custom Scripting Action
First build out your survey page with your hidden value on it. Add a Custom Script Action by clicking Add New Action > Custom Script. Copy and paste the Custom Script below.
%%format = "Y-m-d"; %%now = sgapiStrtotime(sgapiDate(%%format)) + 172800; //Replace 172800 with the amount of seconds you'd like to add or subtract and change the + to a - if you'd like to subtract. %%twodays = sgapiDate('Y-m-d',%%now); sgapiSetValue(3,%%twodays);// 3 is the ID of the Hidden Value
The highlighted elements above will need to be changed to match your survey.
- First, you will want to decide if you are adding or subtracting time. If you are subtracting, change the plus sign to a minus.
- Next decide how much time you'd like to add or subtract. Calculate that time into seconds and put that in place of 172800 (2 days in seconds).
- To finish, change the 3 to the ID of the hidden value you've created. If you are unsure of how to find that ID check out our tutorial on How to Find Question IDs.
Once you have that custom script in place, move that custom script action above your hidden value to make sure it populates.
Now you'll be able to use the merge code for that hidden action later on in your survey!
Now you're ready to test your survey. Is your merge code populating with the date? If so, you've suceeded! Congratulations! If not, double check your hidden value ID and make sure your custom script precedes the hidden value. These are the most common issue we see in support.
Scripting and Other Out-of-the-Box Customizations
We’re always happy to help you debug any documented script. That said, we do not have the resources to write scripts on demand.
If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your customization. Beyond this, you might want to consult with someone on our Programming Services Team; these folks might have the scripting chops to help you to achieve what you are looking for!
@plans @pro @ent