jamar
8 years agoIdeator III
Issue with report creation - Method and AML
Hello,
We currently don't have self service reporting and I am trying to create a report but have ran into an issue. I have created one as a method (to be ran though the reports drop down) and one as AML but neither work.
I can't work out how to get this to display in a tabulated format, get the error
"Line number 40, Error Number: CS0029, Cannot implicitly convert type 'string' to 'Aras.IOM.Item'" on the "return html" line.
The method searches through all ecr records and if they are within the last month and have a change type of defect it will display the records found. The method works if I say "return inn.newResult(result);, but cant convert into the
Innovator inn = this.getInnovator();
Item ecr = inn.newItem("ECR","get");
ecr.setAttribute("select", "item_number, source, trl_product_family, state, trl_change_type, created_on, trl_sup_total_cost_of_change");
ecr = ecr.apply();
string result = "";
// Specify Dates
DateTime today = DateTime.Today;
DateTime month = new DateTime(today.Year, today.Month, 1);
DateTime first = month.AddMonths(-1);
DateTime last = month.AddDays(-1);
//return inn.newResult(Environment.NewLine + first + Environment.NewLine + last +Environment.NewLine);
if (ecr.isError()){ return ecr; }
int totalecrswithdefects = 0;
for(int i=0; i<ecr.getItemCount(); i++)
{
Item curr_part = ecr.getItemByIndex(i);
string e = curr_part.getProperty("item_number","");
string h = curr_part.getProperty("trl_change_type","");
DateTime d = DateTime.Parse(curr_part.getProperty("created_on",""));
if (d.Date>first.Date && d.Date<last.Date && h == "Defect")
{
totalecrswithdefects++;
result = result + Environment.NewLine + e + " " + h + " " + d;
}
else
{
continue;
}
}
var report = inn.getItemByKeyedName("Report","newlostcost");
var style = report.getProperty("xsl_stylesheet");
var html = ecr.applyStylesheet(style,"text");
return html;
OR:
I also cant work out how to use the "less than" operator in the below for the section "and [ecr].created_on<"
I get the error:- '<', hexadecimal value is an invalid attribute character.
<AML>
<Item type="ECR" action="get" where="[ecr].created_on>DATEADD(month, DATEDIFF(month, -1, getdate()) - 2, 0) and [ecr].created_on<DATEADD(ss, -1, DATEADD(month, DATEDIFF(month, 0, getdate()), 0))"</Item>
</AML>
Any ideas?