Reputation: 117
I'm retrieving fields from HP ALM. But here I trouble to get the field names.
BugFactory bf = (BugFactory)qcc.BugFactory;
List bugs = (List)bf.NewList(bf.Filter.Text);
string b5 = Convert.ToString(bg["BG_PROJECT"]);
string b6 = Convert.ToString(bg["BG_STATUS"]);
string b7 = Convert.ToString(bg["BG_TARGET_CYCLE"]);
First two are fine to get result and Last statement showing Invalid field name error.
Please tell me the correct way to get field names.
Thank you.
Upvotes: 1
Views: 2704
Reputation: 68
You can use the Filter of the factory, for example the next is for AuditRecord you can use the samewith BugFactory
AuditRecordFactory auditLog = this.ALMConnection.AuditRecordFactory as AuditRecordFactory;
var auditLogFilter = auditLog.Filter as ITDFilter;
//Get the field list
List fieldList= auditLogFilter.Fields;
UPDATE: I found a complete answer here https://stackoverflow.com/a/24368561/3915468 :)
@TheArtTrooper provide a good answer with the next method
private void ExploreFactoryFieldDefinitions(IBaseFactory factory)
{
List fields = factory.Fields;
foreach (TDField field in fields)
{
FieldProperty field_property = (FieldProperty)field.Property;
if (field_property.IsRequired)
{
Log(String.Format("User Label: {0}\n", field_property.UserLabel));
Log(String.Format("User Column Type: {0}\n", field_property.UserColumnType));
Log(String.Format("DB Column Name: {0}\n", field_property.DBColumnName));
Log(String.Format("DB Column Type: {0}\n", field_property.DBColumnType));
Log(String.Format("DB Table Name: {0}\n", field_property.DBTableName));
}
}
}
Upvotes: 0
Reputation: 1105
See my answer to this question:
It has some sample code that shows how to programmatically determine the fields given a factory object. You have the BugFactory object which is the perfect start.
Upvotes: 1