@loginerror @DeanMauro @radu_bucur
Input:
1.)Column Names <string> / Column Indexes <int>
2.)InOutDataTable
I need to raise Validation Error in 2 cases:
i.) Column Names and Column Indexes are empty : “Please provide value to either fields”
ii.)Column Names and Column Indexers both have values : “Please select either of the fields”
Below is my code. And it is still throwing Validation error (PFA screenshot where Column Indexers = {0} and Column Names = empty)
public class RemoveMultipleColumns:CodeActivity
{
[Category("Input")]
[DisplayName("Column Indexes")]
[Description("Array of column indexes")]
public InArgument<int[]> ColumnIndexes { get; set; }
[Category("Input")]
[DisplayName("Column Names")]
[Description("Array of column names")]
public InArgument<string[]> ColumnNames { get; set; }
[Category("Input")]
[RequiredArgument]
[DisplayName("Input / Output DataTable")]
[Description("Input/Output DataTable")]
public InOutArgument<System.Data.DataTable> InOutDataTable { get; set; }
protected override void CacheMetadata(CodeActivityMetadata metadata)
{
base.CacheMetadata(metadata);
if ((ColumnIndexes != null) && (ColumnNames != null) )
{
ValidationError error = new ValidationError("You can NOT give both fields: Column Indexes and Column Names values");
metadata.AddValidationError(error);
}
if ((ColumnIndexes == null) && (ColumnNames == null))
{
ValidationError error = new ValidationError("Please provide value to either field Column Indexes OR Column Names");
metadata.AddValidationError(error);
}
}
protected override void Execute(CodeActivityContext context)
{
//logic
}
}