Code Task in Workflow assigning wrong values from piped text value | XM Community
Solved

Code Task in Workflow assigning wrong values from piped text value


Badge +2

I have a Code Task that assigns values from the survey to variables that I used to concatenate some text to send to another system.  Everything is working except some of the assignments that I use to pull text from the survey responses.

In the code task, there are a bunch of assignments like this:

    let q3 = `${q://QID3/ChoiceTextEntryValue}`;
    let q8 = `${q://QID8/ChoiceTextEntryValue}`;
    let q4 = `${q://QID4/ChoiceTextEntryValue}`;
    let q6 = `${q://QID6/ChoiceTextEntryValue}`;
    let q5 = `${q://QID5/ChoiceTextEntryValue}`;

These are the last 5 of 20-some.  The problem only occurs with these 5.  

Q3:Customer Company Name
Q8: Customer ID
Q4: Customer Contact Name
Q6: Customer Contact Email
Q5: Customer Contact Phone

For a test, I answered them as:

Q3:Customer Company Name
Q8: Customer ID
Q4: Customer Contact Name
Q6: CustomerContactEmail@example.com
Q5: Customer Contact Phone

When I look at the workflow results, I see this:

let q3 = ``; 
let q8 = `Customer ID`;
let q4 = `Customer Company Name`;
let q6 = `Customer Contact Phone`;
let q5 = `Customer Contact Name`;

Can anyone help me figure out why this is happening?

icon

Best answer by Helfri62 8 May 2024, 21:34

View original

2 replies

Userlevel 3
Badge +6

Hi @Helfri62 ,

 

Depending on how you build your survey, your piped text may be different due to referencing another QID (internal ID) compared to your question or entering “ChoiceTextEntryValue” instead of “ChoiceTextEntryValue/1”.

Badge +2

@Chee Heng_SZ, thanks!

It turns out that I did not understand that the QXX numbers in the survey editor are really LABELS, not IDs.  I constructed my code with copy and paste instead of picking all 30 values from the code task editor.  It turns out that what was labeled as Q3 was actually QID4, for example.  Wow, is that confusing! 

I didn’t know that until I reviewed the problem with the person who set up the survey, and he remembered that this could happen.

For the benefit of anyone else who might not know that, I thought I would follow up on my question.  This help topic on Formatting Questions > Question Numbers explains it.

Leave a Reply