我正在尝试使用WebAPI从Autotask数据库中提取一些Account
entities。而不是通过ID
字段查询,我需要使用UDF "Next Visit"
来拉它,它是Date类型。
我已经说明了正在使用的函数/查询。现在如API文档中所述
要指定字段是UDF,必须在字段标记中添加udf =“true”。您只能为每个查询指定一个UDF字段。
我仍然得到ResponseCode = -1,错误消息"Unable to find next visit in the Account Entity. "
public static Account[] getAccountsWithNextVisitDueIn(DateTime fromDate, DateTime toDate)
{
StringBuilder query = new StringBuilder();
query.Append("<queryxml><entity>Account</entity>");
query.Append("<query><condition operator=\"and\"> ");
query.Append("<field udf=\"true\">Next Visit<expression op=\"greaterthanorequals\">" + fromDate.ToString("dd/MM/yyy") + "</expression></field>");
query.Append("<field udf=\"true\">Next Visit<expression op=\"lessthan\">" + toDate.ToString("dd/MM/yyy") + "</expression></field>");
query.Append("</condition></query></queryxml>");
ATWSResponse response = connHandler.Query(query.ToString());
if(connHandler.Success(response))
{
Entity[] accountEntities = response.EntityResults;
Account[] accounts = Array.ConvertAll(accountEntities, item => (Account)item);
return accounts;
}
return null;
}
使用命令GetFieldInfo查看Account实体的UserDefinedField列表。确保字段名称与您在查询中使用的名称完全相同。
如果您不确定,请在此处粘贴GetFieldInfo for Account的输出。