UpdateDataGeneral

Description

Updates the database with the data in the filled ConfirmitData object. This method is recommended if not using .Net.

Signature
ErrorMessage[] UpdateDataGeneral(string key, TransferDef transferDef, ConfirmitData data, bool applyRules, bool inTransaction, int transactionKey)

Parameters

Name Data Type Description

key

string required

The authentication key

transferDef

TransferDefBase required

The transfer definition object. It can be a SimpleTransferDef or a TransferDef object.

data

ConfirmitData required

DataSet to be Updated.

applyRules

bool

Indicates if data in the update should be verified against constraints in the panel. For instance that data updated for a single match a code from the answer list of the single.

inTransaction

bool

True runs the update in a transaction, False does not.

transactionKey

int

A key, defined by the user to be able to track if the transaction succeded or not (cannot be a negative number).

Response

Data Type Description

Example

var communityPanelSoapClient = new CommunityPanelSoapClient();

// Filter for retrieving all data for panelists with id less than 1000

var transferDef = new TransferDef
{
    ProjectId = "p123456789",
    AllChildrenLevels = true,
    Where = new WhereClause
    {
        Item = new BinaryComparison()
        {
            Type = ComparisonType.LessThan,
            Item = new QueryForm
            {
                Name = "responseid",
            },
            Item1 = new QueryConstant
            {
                Value = "1000"
            }
        }
    },
    Key = "responseid"

};

// Get existing data
var transferResult = communityPanelSoapClient.GetDataGeneral(key, transferDef, null);
var panelData = transferResult.Result;
var dataLevel = panelData.DataLevels.First(x => x.LevelId == "responseid");
var columnToUpdate = Array.FindIndex(dataLevel.Variables, x => x.Name == "test");

// Loop over records and change value in field "test"
foreach (var dataLevelRecord in dataLevel.Records)
{
    dataLevelRecord.Values[columnToUpdate] = "new value";
}

// Send updated data back to panel.
var errorMessages = communityPanelSoapClient.UpdateDataGeneral(key, transferDef, panelData, false, false, -1);

if (errorMessages.Length < 1)
{
    Console.WriteLine($"Data has been updated");
}
else
{
    Console.WriteLine($"Update failed:");
    Array.ForEach(errorMessages, Console.WriteLine);
    Console.WriteLine();
}