"Code" in workflow for variable manipulation without creation in survey flow | XM Community
Question

"Code" in workflow for variable manipulation without creation in survey flow

  • 30 August 2023
  • 9 replies
  • 96 views

Userlevel 1
Badge +2

1. We have a multiple-choice question with 5 options. If someone selects the 2nd or
3rd option, it will be coded as -Yes-. If the selected option is not 2 or 3, it will be
recorded as -No-. And it all should be done by “Code” which is available in work flow.

2. We are implementing this to ensure that we can retrieve this in dashboard data view.


9 replies

Userlevel 6
Badge +14

If you’re building the dashboard inside Qualtrics, you should be able to click on the settings tab in the dashboard and click the blue gear icon next to the field that you are trying to recode. You can recode the options there without it affecting any recodings in your actual survey project outside of the dashboard.

Userlevel 1
Badge +2

If you’re building the dashboard inside Qualtrics, you should be able to click on the settings tab in the dashboard and click the blue gear icon next to the field that you are trying to recode. You can recode the options there without it affecting any recodings in your actual survey project outside of the dashboard.

@ash123 Thankyou for your response but I want to do this by “Code” - which is available in Workflow

Userlevel 1
Badge +2

Hello everyone - Can anyone help me with this?

Userlevel 7
Badge +20

@Adeep You can do it by some much simple way like recode/variable naming. I don’t know you mean it should be done by coding.

Userlevel 1
Badge +2

@Adeep You can do it by some much simple way like recode/variable naming. I don’t know you mean it should be done by coding.

@dxconnamnguyen Thanks, but the client doesn't want us to do anything in the survey flow and recoding in data. They want us to achieve this by using the 'Code' task, which is available in the workflow. Also I request @TomG @JohannesCE @Deepak @ScottG to look into this.

 

Userlevel 6
Badge +23

@Adeep unfortunately I have not used the code workflow task to give advice on this one.  You can try reviewing the following support page on this function Code Task (qualtrics.com)

Userlevel 6
Badge +12

@Adeep maybe something like this?

Assuming that it's a 1 answer MC

function codeTask() {
let selectedChoice = "${q://QID1/ChoiceGroup/SelectedChoices}";

let result;
if (selectedChoice === "two" || selectedChoice === "three") {
result = "Yes";
} else {
result = "No";
}

return {
result: result
};
}

 

Userlevel 1
Badge +2

@Adeep maybe something like this?

Assuming that it's a 1 answer MC

function codeTask() {
let selectedChoice = "${q://QID1/ChoiceGroup/SelectedChoices}";

let result;
if (selectedChoice === "two" || selectedChoice === "three") {
result = "Yes";
} else {
result = "No";
}

return {
result: result
};
}

 

@JohannesCE Thank you so much for replying and answering my query. Could you please let me know how I can drag the variable 'selectedChoice' into the dashboard dataset, so I can view the data in the form of 'Yes' and 'No'?

Userlevel 6
Badge +12

One way to do it could be updating the contact in the XM Directory by adding the result as Embedded Data. You'd have to first create the field in the XM Directory, then you can add the Single profile update task and push the result from the Code task into that field. You would need to also add the Directory Funnel as a source to the Dashboard. Not sure if you have that in place already.

Another way would be perhaps to use the Update Response API api.qualtrics.com/daed82306b1ea-update-response. You would have to set an Embedded Data for the Yes/No questions, then when the response has been taken update it with the API.

Haven't tried this, it's a strange situation, not being allowed to use the Survey Flow or Recoding.

Are you aware that you can also recode in the Dashboard instead of the Survey? You could just add the variable twice in the Dashboard Data and recode it for the second.

Leave a Reply