Results 1 to 4 of 4

Thread: Reporting: Example of using API Methods to bring in Unit's Warranty information

  1. #1
    Join Date
    Aug 2005
    Posts
    2,751

    Reporting: Example of using API Methods to bring in Unit's Warranty information

    The following topic is 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.

    In this example, we want to show in a detailed report template the unit's warranty information that displays in the service workorder entry screen




    1. Download and import the sample report template UNIT WARRANTY INFO Sample report.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.



    2. As always, declare the namespace in the Before Print for the whole report in xtraReport1 " "


    using GZTW.AyaNova.BLL;
    using CSLA;



    3. Example of what is in the Before Print script for the detail band where the unit datafields are:

    private void Detail2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
    ///Only do this if there is a unit selected
    if(!string.IsNullOrEmpty(DetailReportItem.GetCurrentColumnValue("LT_Unit_Label_Serial").ToString()))

    {

    //The Unit object does have a method to retrieve it's ID from it's serial number however the serial number column
    //in the report contains other text besides the serial number so it's not possible to use that method, instead we'll get it from the workorder:


    //first get the id of the Item - note the "DetailReportItem" I'm calling GetCurrentColumnValue on the woitem id
    Guid gWOItemID=new Guid(DetailReportItem.GetCurrentColumnValue("ID").ToString());

    //now that we have the Item we can fetch the workorder from the woitem id
    Workorder w = Workorder.GetWorkorderByRelativeNoMRU(RootObjectTypes.WorkorderItem, gWOItemID);

    //now get the correct workorder item from this workorder
    WorkorderItem wi = w.WorkorderItems[gWOItemID];

    //Now get the unit on this workorder item
    Unit u = Unit.GetItemMRU(wi.UnitID,false);

    //to display the unit's warranty info, need to




    {
    string sDate = "";
    if (u.WarrantyExpiryDateResolved != null)
    sDate = ((DateTime)u.WarrantyExpiryDateResolved).ToLongDateString();
    switch (u.WarrantyStatusResolved)
    {
    case WarrantyStatus.None:
    label3.Text = string.Format("{0}", "Unit is not warrantied." );
    break;
    case WarrantyStatus.Expired:
    label3.Text = string.Format("{0}{1}", "Unit's warranty expired: ", sDate);
    break;
    case WarrantyStatus.Active:
    label3.Text = string.Format("{0}{1}{2}{3}","Unit is warrantied until: ", sDate, " with terms: ", u.WarrantyTermsResolved);
    break;
    }
    }

    }

    }
    Last edited by AyaNova Support; 03-29-2011 at 12:41 PM. Reason: added image
    AyaNova Sales & Support
    www.ayanova.com

  2. #2
    Join Date
    May 2007
    Posts
    36

    Re: Reporting: Example of using API Methods to bring in Unit's Warranty information

    Hi,

    am using this for our own reporting. How would I pull in the model information for the unit ?

    I think I would have to use the unit ID to find the UnitModelID.

    Once I have that what I want to do is get the custome field information (Custom0, Custom1 etc).

    Know the theory, so far have not been able tio implement it !!!

    thanks,
    Martin

  3. #3
    Join Date
    Aug 2005
    Posts
    186

    Re: Reporting: Example of using API Methods to bring in Unit's Warranty information

    Hello Martin, once you have the Unit object (as per the example here) that contains the Unit model Id which is all you need to then fetch the Unitmodel object in a similar fashion to how the unit is retrieved.
    The api is documented here: http://api.ayanova.com/

    Specifically this page shows you the Unit's fields and among them the UnitModelId field:
    http://api.ayanova.com/html/Properti...a_BLL_Unit.htm

    And this page contains the info about UnitModel:
    http://api.ayanova.com/html/AllMembe..._UnitModel.htm

    Which, as you can see from that page, contains the standard GetItem method which can be used to retrieve it.

  4. #4
    Join Date
    May 2007
    Posts
    36

    Re: Reporting: Example of using API Methods to bring in Unit's Warranty information

    Thanks the help John.

    Just in case anyone else reading this:

    UnitModel m=UnitModel.GetItem(u.UnitModelID);

    label6.Text = m.Name.ToString(); // Display the model name

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •