Extracting data from a checklist


Paolo Manfrin

Assuming that you have a specific checklist and you want to extract only selected data the attached pdf gives you an overview how to use the coresuite framework components in order to extract data from a checklist.

In this sample we will use a minimal checklist in order to make it easier to understand.


In this checklist we want to track which serial number has been replaced.

private static void ExtractData(SwissAddonFramework.UI.FunctionButton.FunctionButtonEvent pVal)
string serviceCallId = TextEdit.GetFromUID(pVal.Form, "12").Value;
string item = TextEdit.GetFromUID(pVal.Form, "33").Value;
SwissAddonFramework.Utils.CheckList.CheckListContainer container = new SwissAddonFramework.Utils.CheckList.CheckListContainer("191", serviceCallId);
var checkListArray = container.CheckListArray;
var checklistInstance = checkListArray[0];

foreach (string language in checklistInstance.Instance.GetValues().Keys)
string instanceId = checklistInstance.Instance.InstanceIdentifier;
// before inserting check if this instance has been already extracted
int indexCounter = Convert.ToInt32(SwissAddonFramework.B1Connector.GetB1Connector().ExecuteScalar("SELECT COUNT([U_InstanceID]) from [@SNREPLACEMENT] WHERE U_InstanceID = '" + instanceId + "'"));

if (indexCounter > 0)

// add the current instance
XmlDocument content = checklistInstance.Instance.GetValues()[language];
string oldNS = content.SelectSingleNode("/values/string[@key='Chapter_1.SN_OLD.value']").InnerText;
string newSN = content.SelectSingleNode("/values/string[@key='Chapter_1.SN_NEW.value']").InnerText;
string remarks = content.SelectSingleNode("/values/string[@key='Chapter_1.NOTE.value']").InnerText;

string nextId = SwissAddonFramework.B1Connector.GetB1Connector().ExecuteQueryScalar("select RIGHT('00000000' + CAST(COUNT(Code)+1 AS nvarchar(8)), 8) from [@SNREPLACEMENT]").ToString();
string queryUpdate = @"INSERT INTO [dbo].[@SNREPLACEMENT]
SqlCommand cmd = new SqlCommand();
cmd.CommandText = queryUpdate;
cmd.Parameters.AddWithValue("@Code", nextId);
cmd.Parameters.AddWithValue("@Name", nextId);
cmd.Parameters.AddWithValue("@callID", Convert.ToInt32(serviceCallId));
cmd.Parameters.AddWithValue("@oldSN", oldNS);
cmd.Parameters.AddWithValue("@newSN", newSN);
cmd.Parameters.AddWithValue("@remarks", remarks);
cmd.Parameters.AddWithValue("@item", item);
cmd.Parameters.AddWithValue("@instanceID", instanceId);


A step by step description is provided in the attached pdf




Please sign in to leave a comment.

Didn't find what you were looking for?

New post