Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7173 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

I have a script shown below, that works fine until it gets to the set field steps that increment a counter and a question id. The steps simply put a 1 into each new record instead of adding 1 to each previous value. Anyone know how to fix this so it does increment the fields? I'm stuck until this is working. All help appreciated.

New Record/Request

Set Field [survey Answers::gLoopCounter;0]

Set Field [survey Answers::n_question_id;0]

Loop

Set Field [survey Answers::n_survey_id ;Survey Answers::n_survey_id = Survey Respondents::n_survey_id]

Set Field [survey Answers::n_respondent_id;Survey Answers::n_repondent_id = Survey Respondents::n_dem_respondent_id]

Set Field [survey Answers::gLoopCounter;Survey Answers::gLoopCounter = Survey Answers::gLoopCounter + 1]

Set Field [survey Answers::n_question_id;Survey Answers::n_question_id = Survey Answers::n_question_id + 1]

Exit Loop If [survey Answers::gLoopCounter=40]

New Record/Request

End Loop

Go to Layout [original layout]

  • Newbies
Posted

n_question_id is a number field. It first gets set to 0 and then in the loop it gets set to 1. This works fine. It's the next time through the loop that it set's the n_question_id to 1 again not 2.

If I had a global field then I wouldn't end up with question id's from 1 to 40.

Am I making sense?

Posted

Whats happening here is that there is no value in N_Question the second time through because its not a global. Why not just set N_Question_ID to the gLoopCounter. This will set the Numeric value to your Global value (thus incrementing the question).

(Or set it to "Ngloopcounter+x" where x is the value you want to offset the number by.

Essentially, in your script, N_Question_Id knows nothing about the previous records N_question value.

  • Newbies
Posted

Thanks so much for the assistance. Yep you were right, globals were the key and it solved the problem. I ended up doing the following:

#New respondent answer setup

New Record/Request

Set Field[survey Answers::gLoopCounter2; 0]

Set Field[survey Answers::g_question_id2; 0]

Loop

Set Field[survey Answers::n_survey_id; Survey Answers::n_survey_id = Survey Respondents::n_survey_id]

Set Field[survey Answers::n_repondent_id; Survey Answers::n_repondent_id = Survey Respondents::n_dem_respondent_id]

Set Field[survey Answers::gLoopCounter2; Survey Answers::gLoopCounter2 + 1]

Set Field[survey Answers::gLoopCounter; Survey Answers::gLoopCounter2]

Set Field[survey Answers::g_question_id2; Survey Answers::g_question_id2+ 1]

Set Field[survey Answers::n_question_id; Survey Answers::g_question_id2]

Exit Loop If[survey Answers::gLoopCounter2 = 40]

New Record/Request

End Loop

Go to Layout["Respondents" (Survey Respondents)]

Cheers

Libby - very grateful

smile.gif

This topic is 7173 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.