MultiTenant Lookup editor - Input String incorrect format
See original GitHub issueI’ve been playing around with this one and could use some outside help. I keep getting an “input string is in incorrect format” error. I cant seem to figure out the fix.
I’ve set up as a multitenant. I have a table which acts as my master table. At that table I have a TenantId that is defaulted to 1, thus only one tenant can see data in that table. I also have another ID, CustomerID, which I have joined to the TenantId from the tenants table. I use this so that I can use the CustomerID to designate the TenantId in the SqlViews thus, create reports which clients can only see the data pertaining to them. Those views work perfectly.
I created the following lookup script to deal with the search box:
[LookupScript(“FMCorp.MatrixCustomerName”)] public class MatrixCustomerNameLookup : MultiTenantRowLookupScript<MyRow> { Field fld = MyRow.Fields.CustomerName;
public MatrixCustomerNameLookup()
{
IdField = TextField = fld.PropertyName;
}
protected override void PrepareQuery(SqlQuery query)
{
query.Distinct(true)
.Select(fld)
.Where(
new Criteria(fld) != "" &
new Criteria(fld).IsNotNull()
);
AddTenantFilter(query);
}
protected override void ApplyOrder(SqlQuery query) { }
}
Matrix row designates the fields affected like this:
[DisplayName(“Customer Id”), ForeignKey(“[dbo].Tenants”, “TenantId”), LeftJoin(“cust”), Width(100), AlignCenter] //Join TenantID from Tenant Table to Matrix Table. Identifier is “cust” [LookupEditor(“Administrative.Tenants”)]//Added for DropBox type Lookup public Int32? CustomerId { get { return Fields.CustomerId[this]; } set { Fields.CustomerId[this] = value; } } [DisplayName(“Customer Name”), Expression(“cust.TenantName”), Width(100), AlignCenter] //Calls upon Name column from Customer Table. [LookupEditor(typeof(Script.MatrixCustomerNameLookup))] public String CustomerName { get { return Fields.CustomerName[this]; } set { Fields.CustomerName[this] = value; } }
I then added the lookup script to the columns table for customer name but I also hid the CustomerId
.
//Client and Location Information
[Hidden]
public Int32 CustomerId { get; set; }
[EditLink, LookupEditor(typeof(Script.MatrixCustomerNameLookup)), QuickFilter]
public String CustomerName { get; set; }
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)

Top Related StackOverflow Question
Check the
IdField = TextField = fld.PropertyName;where fld isMyRow.Fields.CustomerName. Second my opinion there is an error.The IdField should be fld.CustomerId
Where is your query