on 2006 Nov 07 2:11 AM
Hello,
The DI's object UserFieldsMD object requires the field id parameter in the GetByKey method. I want to check the existence of user field before add or update in my Add on. but, i don't know the field id. Any solution or sample code??
Regards,
Kit
Most people use the CUFD table to check if a UDF exist:
Something like this
/// <summary>
/// Check if a field exist on a specific table
/// </summary>
/// <param name="tableName">The name of the table</param>
/// <param name="uid">The name of the field</param>
/// <returns>If the field exist</returns>
public static bool ExistField(string tableName, string uid)
{
try
{
B1Recordset rs = B1Recordset.DoQuery("SELECT COUNT(*) AS udfcount FROM CUFD WHERE TableID LIKE '%" + tableName + "' AND AliasID='" + uid + "'");
int udfcount= rs.GetValueAsInteger("udfcount");
rs = null;
GC.Collect();
return (udfcount== 1);
}
catch
{
return false;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
105 | |
8 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.