take-survey Widget Submit Button

abhi56
Tera Contributor

#want to customize take survey widget submit button 7community.PNG#n portal#

#I am using the Clone version of 1)surveys and Assessmet  widget id=take_assessment 

which ultimately call "take-survey" widget i am using the cloned version of it also for my customization 

in my case i want to change the features of the submit button 

on clicking of the submit button user should get a alert 

and after submit it should redirect to a particular link ...I tried to identify the on click function for the submit button in the client script but it is not working....

 

 

maybe this is the function for the submit function

c.submitAjax = function(formdata) {
   
        // first stringify the formData
        var stringifiedFormData = JSON.stringify(formdata);
        // then encode the stringified form data to handle any special characters and pass this to processor
        // this will be decoded in processor
        var encodedFormData = encodeURIComponent(stringifiedFormData);
       
        $http({
            method: 'POST',
            url: '/sp_survey.do',
            data: encodedFormData,
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'
            }
        })
        .success(successHandler);

        function successHandler(responseData) {
            if (responseData.success === true || responseData.success === 'true') {
                if (formdata.original_action == 'save' || formdata.original_action  == 'submit') {
                    $scope.server.get({
                        action: 'log_assessment',
                        assessmentDetails: {type : c.data.evaluation_method_display, action_name : formdata.original_action , table : 'asmt_assessment_instance' , id : c.data.instanceId , name : c.data.title}
                });
                }
                var conclusion = c.data.parameterizedMsgsMap.submitted_msg;
                c.data.conclusion = (c.data.conclusion && c.data.conclusion.length > 0) ? c.data.conclusion : conclusion;
                if (formdata.sysparm_action == 'submit' || formdata.updateSuccessMessage) {
                    if (formdata.sysparm_action == 'submit') {
                        if (c.data.refreshInterval && c.data.refreshInterval > 0) {
                            c.data.successMessage = c.data.conclusion;
                            $timeout(function() {
                                $window.location.reload();
                            }, c.data.refreshInterval * 1000);                      
                        } else if (c.data.redirect_url && c.data.redirect_url.length > 0)
                             window.location.href = c.data.redirect_url;    
                        else
                             c.data.successMessage = c.data.conclusion;
                    } else if (formdata.sysparm_action == 'save')
                        c.data.successMessage = c.data.parameterizedMsgsMap.saved_msg;
                    else if (formdata.sysparm_action == 'cancel')
                        c.data.successMessage = c.data.parameterizedMsgsMap.not_saved_msg;
                }
            } else {
                c.showInlineErrorMessage(i18n.getMessage("Something went wrong. Please try again later."));
                c.invalidSurvey = true;
            }

            c.data.showMessage = true;
        }
    };
7 REPLIES 7

@Juhi Poddar  i tried using the above but no luck,I also tried to remove the submit button adding a new button with diff name then also nothing...

abhi56_0-1735099539261.png

 

@Juhi Poddar if i do inspect element i can see in html submit button is defined but n widget i could not fine that ,</button><button ng-disabled="isSavingOrSubmitting()" class="btn btn-primary ng-binding" style="float:right;width:48%" ng-click="validatePageAndSave('submit')" ng-show="currentPage == pages.length-1 &amp;&amp; !formModel.readonly_form" aria-hidden="false">Submit</button></div></div></sp-assessment-nav-buttons>commnunity 10.PNG

Hello @abhi56 

Yes, I saw that.