6. Form Data API
The Form Data API provides access and update to the data of eBA Forms without the need for database connections and queries. This section describes with examples of properties and methods used to access fields, tables, and lists of forms through the eBAForm object using the FormDataAPI.
6.1. eBAForm
The eBAForm object contains all the objects on the form. This allows changes to be made to objects.
6.1.1. Properties
•Form
Definition: The name information is the name of the form object that is dropped. Type: System.String Declaration: public string Form{ get; }
•Id
Definition: The id of the form object that is opened. Type: System.Integer Declaration: public int Id { get; }
• CreatorUserID
Definition: The id of the user who created the form. Type: System.String Declaration: public string CreatorUserID { get; set; }
•Creator
Definition: The approval type information of the person who will approve the form. Type: eBAFormData.ApproverType Declaration: public eBAFormData.ApproverType Creator { get; set; }
• CreateDate
Definition: The creation date of the opened form. Type: System.DateTime Declaration: public DateTime CreateDate { get; set; }
• DocumentId
Definition: It is the form id information created according to the format specified in the flow design. Type: System.String Declaration: public string DocumentId { get; set; }
• DocumentPath
Definition: It is the location path information of the document to which the opened form belongs. Type: System.String Declaration: public string DocumentPath { get; }
• DocumentVersion
Definition: It is the version information of the document to which the opened form belongs. Type: System.Integer Declaration: public int DocumentVersion { get; set; }
• Deleted
Definition: Information about whether the form that is opened is a deleted form. Type: System.Boolean Declaration: public bool Deleted { get; set; }
• OwnerDocumentId
Definition: The id information of the parent document assigned during the flow design. Type: System.Integer Declaration: public int OwnerDocumentId { get; set; }
• OwnerProcessId
Definition: It is the id information of the process to which the parent document assigned during the flow design belongs. Type: System.Integer Declaration: public int OwnerProcessId { get; set; }
• Process
Definition: The name of the process to which the opened form belongs. Type: System.String Declaration: public string Process { get; }
• UserId
Definition: The id of the user who created the form. Type: System.String Declaration: public string UserId { get; set; }
• Status
Definition: The current status of the document. Type: System.Integer Declaration: public int Status { get; set; }
• ReadOnly
Definition: Information about whether the form that is opened is read-only or not. Type: System.Boolean Declaration: public bool ReadOnly { get; set; }
• ProfileOwner
Definition: The path of the opened form in the document management system. Type: System.String Declaration: public string ProfileOwner { get; set; }
• Fields
Definition: A list of objects on a form. Type: eBAFormData.FormFieldCollection Declaration: public eBAFormData.FormFieldCollection Fields { get; }
Example: How to access fields eBAFormData.eBAForm form = new eBAFormData.eBAForm(71);
string firstName = form. Fields["txtFirstName"]. AsString; string lastName = form. Fields["txtLastName"]. AsString; DateTime birthday = form. Fields["txtBirthDay"]. AsDateTime; RadioButton int male = form. Fields["rbMale"]. AsInteger; The RadioButton will return 1 if it is selected, 0 if it is not
CheckBox int english = form. Fields["cbEnglish"]. AsInteger;
Example: How to modify fields eBAFormData.eBAForm form = new eBAFormData.eBAForm(71);
form. Fields["txtFirstName"]. AsString = "George Michael"; form. Fields["cbEnglish"]. AsInteger = 1;
We call the update method for the changes to take effect. form. Update();
• CheckLists
Definition: A list of objects of type checklist on a form. Type: eBAFormData.CheckListCollection Declaration: public eBAFormData.CheckListCollection CheckLists { get; }
•Columns
Definition: A list of columns of objects on a form in the database. Type: eBAFormData.ColumnCollection Declaration: public eBAFormData.ColumnCollection Columns { get; }
• Details
Definition: A list of objects of the details type on a form. Type: eBAFormData.FormDetailsCollection Declaration: public eBAFormData.FormDetailsCollection Details { get; }
Example:
How to access a form in the details object, how to modify it?
eBAFormData.eBAForm form = new eBAFormData.eBAForm(71);
foreach(var row in dtlExperiences.Rows)
{
eBAForm modalForm = row. Form;
string companyName = modalForm.Fields["txtCompanyName"]. AsString; modalForm.Fields["txtCompanyName"]. AsString = companyName + "_"; modalForm.Update();
}
Example:
How to delete a row from details object?
if(dtlExperiences.Rows.Count```>```1)
{
dtlExperiences.Rows[dtlExperiences.Rows.Count-1]. Form.Deleted = true; dtlExperiences.Rows[dtlExperiences.Rows.Count-1]. Form.Update(); dtlExperiences.Rows[dtlExperiences.Rows.Count-1]. Delete(); form. Update();
}
Example:
How to add a new row to the details object?
WorkflowDocument doc = workflowManager.CreateDocument("Project1",
"Form2");
if(doc != null)
{
eBAForm modalForm = new eBAForm(doc. DocumentId); modalForm.Fields["txtCompanyName"]. AsString = "Bimser"; modalForm.Fields["txtStartDate"]. AsDateTime = DateTime.Now.AddYears(-1); modalForm.Fields["txtLeaveDate"]. AsDateTime = DateTime.Now; modalForm.Update();
dtlExperiences.Rows.Add(doc. DocumentId);
}
Form.Update();
• DetailsGrid
Definition: A list of detail table-type objects on a form. Type: eBAFormData.FormDatailsGridCollection Declaration: public eBAFormData.FormDatailsGridCollection DetailsGrid { get; }
Example:
How to access and modify the data contained in the detail table object
eBAFormData.eBAForm form = new eBAFormData.eBAForm(71);
FormDetailsGrid dtlEducation = frm. DetailsGrids["dtlEducation"]; foreach(var row in dtlEducation.Rows) { string level = row["listLevel"]. AsString; string schoolName = row["txtSchoolName"]. AsString; double grade = row["txtGrade"]. IsNull ? 0 : (double)row["txtGrade"]. Value; row["txtGrade"]. Value = grade + 1; } form. Update();
Example:
How to add a new row to the detail table or delete an existing row?
eBAFormData.eBAForm form = new eBAFormData.eBAForm(71);
FormDetailsGrid dtlEducation = frm. DetailsGrids["dtlEducation"]; if(dtlEducation.Rows.Count == 0){ dtlEducation.Rows.Add(); } else { dtlEducation.Rows[dtlEducation.Rows.Count-1]. Delete(); } form. Update();
• Lists
Definition: A list of list-type objects on a form. Type: eBAFormData.FormListCollection Declaration: public eBAFormData.FormListCollection Lists { get; }
Accessing list objects and modifying data in the list object: foreach (var item in frm. Lists["listHobbies"]. Rows) { string h += item. Text + " " + item. Value + "-"; item. Text = item. Text + "x"; }
• Tables
Definition: A list of table-type objects on a form. Type: eBAFormData.FormTableCollection Declaration: public eBAFormData.FormTableCollection Tables { get; }
6.1.2. Methods
• eBAForm(int)
Description: Fetches the eBA form with the specified id. Parameters: id: Specifies the id of the form to be fetched. Return type: eBAForm
eBAFormData.eBAForm form = new eBAFormData.eBAForm(71);
• eBAForm(int, string, string)
Description: Returns the form with the specified parameters. Parameters: id: Specifies the id of the form to be fetched. process: Specifies the process to which the form to be brought belongs to. form: Specifies the type of form to be brought. Return type: eBAForm eBAFormData.eBAForm form = new eBAFormData.eBAForm(71, "Project1", "Form1");
• Update()
Definition: Used so that changes made to the form can take effect.
eBAFormData.eBAForm form = new eBAFormData.eBAForm(71); Operations on a form form. Update();