I want to get a data from survey form and total data stores one field in problem table suggest me a

sudhakar111
Tera Contributor

 i created one survey form .

I want to get  data from survey form 

And what data i get that data store into problem table field

Suppos :

In survey form that data is 1+2+3= 6 in that 6 stores into problem table field. I want any script from BR.

1 REPLY 1

Sai Shravan
Mega Sage

Hi @sudhakar111 ,

To retrieve data from a survey form and store it in a field in a problem table, you can create a business rule that runs on the survey response table after insert or update. Here is an example

 

Create a new business rule on the survey_response table, with the following settings:

  • When to run: After
  • Advanced: True

In the script section of the business rule, write the following code:

(function executeRule(current, previous /*null when async*/) {
	
    // Get the values of the survey questions
    var question1Value = parseInt(current.variables.<question1_name>.getDisplayValue());
    var question2Value = parseInt(current.variables.<question2_name>.getDisplayValue());
    var question3Value = parseInt(current.variables.<question3_name>.getDisplayValue());
    
    // Calculate the total score
    var totalScore = question1Value + question2Value + question3Value;
    
    // Store the total score in the problem field
    var problem = new GlideRecord('problem');
    if (problem.get(current.parent)) {
        problem.<field_name> = totalScore;
        problem.update();
    }
	
})(current, previous);

This code retrieves the values of the specified survey questions from the survey response record, converts them to numbers, sums them, and then updates the corresponding problem record with the total score in the specified field.

Regards,
Shravan

Please mark as help and correct solution, if this helps you.

Regards,
Shravan
Please mark this as helpful and correct answer, if this helps you