The following topics about using the AyaNova developers API with reports are examples we have provided for experienced developers.
If you do not have development experience, we are happy to provide you with a quote to prepare a specific custom report that uses the API to obtain data not available through its datasets. Contact support@ayanova.com with details of what you would like - i.e. from what grid the report would be available from, what data it is that you want, example of use, etc.
Normally via a detailed service workorder report, the Rate Cost, Charge, Account Number and Description etc are not available in the Field List.
Using the API, you can obtain and display this information in a report.
-
First example refer to the sample report template http://www.ayanova.com/Downloads/ReportTemplates/APISampleDispatchingReportwithadditionalRatefields.zip and review its scripts for an example of use.
-
You will also want to refer of course to the http://api.ayanova.com business object library.
-
As always, declare the namespace in the Before Print for the whole report in xtraReport1 to save typing: " "
[i]using GZTW.AyaNova.BLL;
using CSLA;[/i]
- And then below is a copy of what is in the details Before Print script " "
[i]private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{[/i]
object o = DetailReportScheduledUsers.GetCurrentColumnValue(“ID”);
[i]if (o != null)
{
System.Guid g=(System.Guid)o;
//See if it’s empty:
if(g!=Guid.Empty)
{
//now we get the scheduled user object using the id that we got above
//GetDescendant<T> where T is the type of the descendant object
WorkorderItemScheduledUser wis = Workorder.GetDescendant<WorkorderItemScheduledUser>(g);
//below shows displaying properties of that specific scheduled user object - in this case, its Start Date
label4.Text = wis.StartDate.ToString();[/i]
[i]//now we want to get the ID of the rate of that scheduled user
//but rate could be empty so only do this if there is actually a rate selected
if (wis.ServiceRateID!=Guid.Empty)
{
//Fetching a list of one rate means we can access the first item in the list
//using array notation:
RatePickList.RatePickListInfo i=RatePickList.GetListOfOneSpecificRate(wis.ServiceRateID)[0];
//now can access all the properties of this single RatePickListInfo item:
//string RateName=i.Name;
//decimal RateCharge=i.Charge;
//etc etc[/i]
[i]label1.Text = i.Name;
label2.Text = i.Charge.ToString();
label5.Text = String.Format(“the charge is: {0} for rate: {1}”, i.Charge.ToString(“C”), i.Name);
label7.Text = i.Charge.ToString(“C”) + " " + i.Name;
}[/i]
[i]}
}[/i]
}
- Second example refer to the sample report template http://www.ayanova.com/Downloads/ReportTemplates/APISampleDispatchingReportwithadditionalRatefieldsbutwithcachedRatepicklist.zip and review its scripts for an example of use. You will also want to refer of course to the http://api.ayanova.com business object library.
This example illustrates a better performing way of doing the above with a cached rate list. This saves time fetching rate info from the database for every record, instead it fetches them all at once up front in the report header and re-uses them later:
in xtraReports1 (header) Before Print
using GZTW.AyaNova.BLL;
using CSLA;
//define the RatePickList so that it is accessible from in the report elsewhere
RatePickList plRates = null;
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
//now fill the RatePickList (getting all rates - not filtered by region)
plRates = RatePickList.GetList(false);
}
And in its detail band’s Before Print (note change of Fetching the rate from the prefilled picklist)
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
object o = DetailReportScheduledUsers.GetCurrentColumnValue(“ID”);
if (o != null)
{
System.Guid g=(System.Guid)o;
//See if it’s empty:
if(g!=Guid.Empty)
{
//now we get the scheduled user object using the id that we got above
//GetDescendant<T> where T is the type of the descendant object
WorkorderItemScheduledUser wis = Workorder.GetDescendant<WorkorderItemScheduledUser>(g);
//below shows displaying properties of that specific scheduled user object - in this case, its Start Date
label4.Text = wis.StartDate.ToString();
//now we want to get the ID of the rate of that scheduled user
//but rate could be empty so only do this if there is actually a rate selected
if (wis.ServiceRateID!=Guid.Empty)
{
//Fetching the rate from the prefilled picklist - the rate selected for that specific scheduled user object
RatePickList.RatePickListInfo i=plRates[wis.ServiceRateID];
//now can access all the properties of this single RatePickListInfo item:
//string RateName=i.Name;
//decimal RateCharge=i.Charge;
//etc etc
label1.Text = i.Name;
label2.Text = i.Charge.ToString();
label5.Text = String.Format(“the charge is: {0} for rate: {1}”, i.Charge.ToString(“C”), i.Name);
label7.Text = i.Charge.ToString(“C”) + " " + i.Name;
}
}
}
}