We are unable to get custom scripting to work for multiplication.


My colleague and I have been trying all day to do something with custom scripting that is conveyed as being pretty simple on the docs. So we know we must be doing something wrong!

Ultimate goal backstory:

User wants a product at qty Z.
Product has 1yr (A) and 3yr(B) support SKUs that are configured like this:

1 year of support = Z x A
2 years = 2Z x A
3 years = Z x B
4 years = (Z x A) + (Z x B)
5 years = (2Z x A) + (Z x B)

We then want the email action to display to the recipient output based on the above.

Example: They want 15 product Z with 5 years of support.
Recipient sees the below in an email (bold text would be result of merge code):

1 year support: 30
3 year support: 15


Basically, we just want to take the user input for Question ID 770, and multiply it by user input for Question ID 771.
We’d like to then reference the result in our email action.

We know we should probably be using a hidden value along with our custom script (right?), and we want to setup if/then/else as well. However, we can’t even get the basic script to function as the docs say it should. We’ve even copy/pasted the exact text from the example scripts in the docs, and those either don’t calculate or don’t display anything at all!

We’d be very appreciative of any help that the community may be able to provide us.

Thank you in advance!

Jim W (Moderator) answered

    Thanks for the clear explanation of what you are trying to achieve.

    It is difficult to diagnose a coding problem without being able to see the code.  If you could provide the Community with a relevant sample of your actual code it would be easier to help you.

    Our method for handling this type of action would be to create a hidden question (https://help.surveygizmo.com/help/hide-question-by-default) and then use the sgapiSetValue function (https://script.surveygizmo.com/help/sgapisetvalue) to place the results of our calculation as the response to the question.  We can then use merge codes to place that number anywhere we want to. 

    Jim W (Moderator) answered


      Question stats

      • Active
      • Views890 times
      • Answers1 answer
      • Followers1 follower