Help Center / Questionnaire nodes / General settings / Global General Settings - Settings

Global General Settings - Settings

Global General Settings - Settings

Settings

Survey External Actions

Crearte New Action

Trigger Scenarios
  • On Forward Entry: Triggers when entering the current question from the previous one.
  • On Forward Leave: Triggers when moving from the current question to the next one.
  • On Backward Entry: Triggers when returning to the current question from a previous one.
  • On Backward Leave: Triggers when moving back from the current question to a previous one.
Type of Action
  • Send Email: Sends an email to a specified email address. Requires setting the recipient's email address, email subject, and the email body text.
  • Send SMS: Sends an SMS message to a specified phone number. Sending SMS requires inputting the specified SMS service API call interface and accessing the required parameters according to the API specifications.
  • Invoke API: Calls a specified API, supporting four different methods: GET, POST, FAKE, and EMBED. By default, it sends via HTTPS.
  • Condition: Sets logical judgment conditions. After setting logical judgment conditions, the specified action will only be triggered when the conditions are met upon encountering the trigger scenario.

Answer Validation

Interface Request Validation
Interface Request Methods
  • GET: Requests a remote interface using HTTP GET, with parameters appended to the URL as a queryString.
  • POST: Requests a remote interface using HTTP POST, with parameters placed in the body.
  • FAKE: A custom request method.
  • EMBED: A custom request method.
GET
    {  
        result: {string|number|boolean}   // The calculation result. For verification interfaces, returning false indicates failure, while returning true indicates success. For non-verification interfaces, it returns a numerical value or string as the calculation result.  
        message?: string // For verification interfaces, if the result property is false (indicating verification failure), a verification failure message should be carried through the message property.  
    }  
 
  • URLs starting with "https://": Upon receiving the returned result, the user will be redirected to this address, leaving the questionnaire.
  • Messages starting with "vital:": Upon receiving the returned result, a message will pop up and terminate the answering process.
  • Other messages: The message will be displayed in a sliding warning popup window.
POST
FAKE
  • Use the FAKE method to call the interface at https://xxx.test.com/plugin/sum_gt0, which requires two parameters, number1 and number2. The purpose of this interface is to determine whether the sum of the two numbers is greater than 0.
  • Additionally, call the interface at https://xxx.test.com/plugin/gt, which also requires two parameters, number1 and number2. The purpose of this interface is to determine whether number1 is greater than number2.
  1. First, write a script according to the following specifications:
(function () {
    // The first three lines are written this way, and this is a fixed rule.
    var plugin = window.CFPlugin = window.CFPlugin || {};
    var server = plugin.fakedServers = plugin.fakedServers || {};
    var space = plugin.currentSpace; // This variable represents the current namespace or space.

    /**
     * Add a method to `server` according to the following rule. This method will be responsible for handling requests to the `sum_gt0` interface under this namespace.
     * In other words, requests made to `https://xxx.test.com/plugin/sum_gt0` will actually invoke this method, which will receive and process the request.
     */
    server[space + '/sum_gt0'] = function (data) {
        // This uses the two properties `number1` and `number2` in `data` as parameters.
        // The return format follows the specified rules above.
        return {
            result: Number(data.number1) + Number(data.number2) > 0, // Note: Corrected the addition to use Number() for both parameters.
            message: 'message', // This is a placeholder message.
        };
    };
    // Annotate the parameter specifications for this method in this way.
    // However, there's a mistake here because the annotation should be for the correct method name.
    // Corrected line should be:
    server[space + '/sum_gt0'].params = ['number1', 'number2']; // Corrected the method name and added the correct parameters.

    /**
     * Add a method to `server` according to the following rule. This method will be responsible for handling requests to the `gt` interface under this namespace.
     * In other words, requests made to `https://xxx.test.com/plugin/gt` will actually invoke this method, which will receive and process the request.
     */
    server[space + '/gt'] = function (data) {
        // This uses the two properties `number1` and `number2` in `data` as parameters.
        // The return format follows the specified rules above.
        return {
            result: Number(data.number1) > Number(data.number2), // Note: Corrected the comparison to use Number() for both parameters.
            message: 'message', // This is a placeholder message.
        };
    };
    // Annotate the parameter specifications for this method in this way.
    // Corrected line should be associated with the correct method name:
    server[space + '/gt'].params = ['number1', 'number2']; // Added the correct parameters for the 'gt' method.

    // Additional explanatory notes:
    // Therefore, requests to `https://xxx.test.com/plugin/test_2` will be handled by the following method.
    server[space + '/test_2'] = function (data) {
        // Input code here.
        // Specific rules are written inside this method.
        // Placeholder return statement:
        return {...}; // Replace `{...}` with the actual return object.
    };

    // If you want to fake the `https://example.cf.io/fake/test` interface,
    // then you need to deploy a `fake.js` script to `https://example.cf.io` and write it according to the above format, with a 'test' method included.
})();
EMBED
Interface Name
Parameters
Interface Code
  • year parameter: Represents the year.
  • name parameter: Represents the name of the Chinese zodiac.
    var zodiacs = ['Mouse', 'Ox', 'Tiger', 'Rabbit', 'Dragon', 'Snake', 'Horse', 'Goat', 'Monkey', 'Chicken', 'Dog', 'Pig'];
    // Define a function to get the zodiac sign corresponding to a given year
    var getZodiac = function (year) {
        // The Chinese lunar zodiac signs repeat every 12 years, and the corresponding zodiac sign is determined by taking the remainder of the year.
        // However, due to the fact that the starting year of the zodiac signs (such as the Jiazi year corresponding to the Year of the Mouse) does not fully correspond to the Gregorian calendar year,
        // a simple adjustment method is adopted here: process the remainder to match the actual zodiac sign.
        // Note: The processing method here is a simplified example and does not accurately reflect the conversion between the lunar and Gregorian calendars.
        var extra = year % 12;
        extra = extra < 4 ? 12 - 4 + extra : extra - 4;

        return zodiacs[extra];
};

// Return a function that takes a data object as a parameter and checks if the year matches the zodiac sign.
return function(data) {

    var year = Number(data.year.trim()); // Extract and convert the year to a number.
    var name = data.name.trim(); // Extract and remove any leading or trailing whitespace from the zodiac sign name.

    // Check if the zodiac sign for the given year or the previous year matches the provided zodiac sign name.
    // Considering that the date of the Lunar New Year may fall at different times within the Gregorian calendar year, two years are checked here.
    var valid = getZodiac(year) === name || getZodiac(year - 1) === name;

    // Return a result object containing the matching result and the corresponding message.
    return {
        result: valid, 
        message: valid ? '' : 'The zodiac sign and year do not match'
    }
}
Test Code
javascript
return [  
    {  
        params: {  
            year: '1989',  
            name: 'snake'  
        },  
        result: true  // 1989 is the Year of the Snake, so the result should be true.
    },  
    {  
        params: {  
            year: '1989',  
            name: 'Mouse'  
        },  
        result: false // 1989 is not the Year of the Rat, so the result should be false.
    },  
    {  
        params: {  
            year: '1991',  
            name: 'Goat'  
        },  
        result: true // 1991 is the Year of the Goat (or Sheep, depending on the cultural context), so the result should be true.
    }  
    ];
Using the EMBED Interface
Built-in Logic Validation

Validation Settings

Allow Continuing on Validation Failure
Question Backtracking Settings
API Request Judgment
Built-in Logic Judgment
  • When the interface returns a rollback permission, it will determine whether to rollback based on the result of the built-in logic judgment.
  • When the interface returns a no-rollback permission, regardless of the result of the built-in logic judgment, a rollback cannot be performed.
Return to Question When Above Conditions Are Met

Advanced Settings

Hidden Question
Show When Only One Reference Option Exists
  • No: Do not show it to the respondent and automatically select the option.
  • Yes: Still show it to the respondent.
  • When Conditions Are Met: Show it to the respondent only when the logical condition settings are met.