"Code" in workflow for variable manipulation without creation in survey flow | XM Community
Skip to main content
Question

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


Forum|alt.badge.img+2
  • Level 2 ●●
  • 7 replies

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

Forum|alt.badge.img+14
  • Level 5 ●●●●●
  • 276 replies
  • August 30, 2023

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.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • August 31, 2023
ash123 wrote:

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


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • August 31, 2023

Hello everyone - Can anyone help me with this?


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • 1091 replies
  • August 31, 2023

@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.


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • August 31, 2023
dxconnamnguyen wrote:

@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.

 


Forum|alt.badge.img+32
  • Level 6 ●●●●●●
  • 241 replies
  • August 31, 2023

@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)


JohannesCE
Level 6 ●●●●●●
Forum|alt.badge.img+12
  • Level 6 ●●●●●●
  • 144 replies
  • August 31, 2023

@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
    };
}

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 7 replies
  • August 31, 2023
JohannesCE wrote:

@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'?


JohannesCE
Level 6 ●●●●●●
Forum|alt.badge.img+12
  • Level 6 ●●●●●●
  • 144 replies
  • August 31, 2023

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