SetRespondentUniqueKey
Description
Sets the key that should be unique for the respondents.
This method gives you the opportunity to define your own unique key for the respondents. The name for the key must be an already existing field in the respondents table. The field you chose must also contain unique values. If the field does not contain unique values or the field does not exist, an exception is thrown. |
Signature
void SetRespondentUniqueKey(string key, string projectId, string uniqueKey)
Parameters
Name | Data Type | Description |
---|---|---|
key |
string required |
The authentication key |
projectId |
string required |
The project ID. |
uniqueKey |
string required |
The name of the unique key. |
Example
//***************************************************
//
// Set a unique key for the respondents
// (for eaxample a user defined customer key)
//
//***************************************************
// Initiate webservice
SurveyDataSoapClient sd = new SurveyDataSoapClient();
//Get all the respondents
DataSet respondents = sd.GetRespondents(key,
SurveyDataUtil.NewRespondentTransferDef(
true,false,projectID));
//Add the new custom key to the respondents. We assume
//that it does not exist.
respondents.Tables[0].Columns.Add("CustomKey");
for(int i=0;i<=respondents.Tables[0].Rows.Count-1;i++)
{
respondents.Tables[0].Rows[i]["CustomKey"] = i;
}
//Update the respondents. We use a transaction
//because we will ensure that all respondents get a key.
sd.UpdateRespondents(key,projectID,respondents,true,true,"",true,12121212);
//Check if the transaction succeeded.
DataSet transaction = sd.GetTransactionStatus(key,12121212);
if(Convert.ToBoolean(transaction.Tables[0].Rows[0]["ErrorFlag"]))
{
//Set the "CustomKey" to be the unique key
sd.SetRespondentUniqueKey(key,projectID,"CustomKey");
}