Results 1 to 2 of 2

Thread: Reporting: Example of using API Methods to display Client's Custom fields and Unit's Custom fields in Service WO report

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

    Reporting: Example of using API Methods to display Client's Custom fields and Unit's Custom fields in Service WO report

    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.



    In this example, we want to show the client's Custom fields and the Unit's Custom fields in the Sample Detailed Service Workorder with Grand Total report from the service workorder grid. Normally these custom fields are not available for reporting off of from the available datasets in the Service Workorder grid, but with the API we can do so now with AyaNova 6.5 and higher.



    1. Download and import the sample report template API Sample Custom fields in - Detailed Service Workorder with Grand Total.zip and review its scripts for an example of use.

    2. You will also want to refer of course to the http://api.ayanova.com business object library.

    3. Declare the namespace in the Before Print for the whole report in xtraReport1


    using GZTW.AyaNova.BLL;
    using CSLA;








    4. Design panel has additional fields added set to show in red so that you can easily see while following along




    5. Detail1 band's Before Print script shows example of getting the client's Custom0 field to display on this report. Again, refer to the http://api.ayanova.com classes for what is available to use.

    //API EXAMPLE
    //--------------------------------------------------------------------------------------
    //Use the AyaNova API to pull out the value of the custom fields for the current client

    //Get the client's internal ID value from their name
    Guid gClientID=Client.IDFromName(DetailReport.GetCurrentColumnValue("LT_O_Client").ToString());

    if(gClientID!=Guid.Empty)
    {
    Client c = Client.GetItemNoMRU(gClientID);//NoMRU so that this client won't appear in the recent items drop down box in AyaNova UI

    //Get client's custom field zero content into the report
    txtCustom0.Text=c.Custom0;

    //Do the same thing with Custom field one but fancier with localized text for the label
    label2.Text=AyaBizUtils.LocaleText.GetLocalizedText("Client.Label.Custom1");

    //Use the c# question mark conditional operator to display alternate text if the field is empty
    txtCustom1.Text = string.IsNullOrEmpty(c.Custom1) ? "Custom 1 is empty" : c.Custom1;

    //repeat as needed for any other custom fields.
    }
    //---------------------------------------------------------------------------------------


    Detail2 band's Before Print script shows example of getting the Unit's Custom0 field to display

    //API EXAMPLE
    //--------------------------------------------------------------------------------------
    //Use the AyaNova API to pull out the value of the custom fields for the current unit

    //Only do this if there is a unit selected for better performance
    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:

    Guid gWOItemID=new Guid(DetailReportItem.GetCurrentColumnValue("ID").ToString());//because it's the "DetailReportItem" I'm calling GetCurrentColumnValue on it's the woitem id

    //Fetch the workorder from the woitem id
    Workorder w = Workorder.GetWorkorderByRelativeNoMRU(RootObjectTypes.WorkorderItem, gWOItemID);

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

    //Get the unit on this workorder item
    Unit u = Unit.GetItem(wi.UnitID);
    txtUnitCustom0.Text=u.Custom0;

    }

    //---------------------------------------------------------------------------------------



    6. Using the above example, now what is in the Client's Custom fields now are able to show on the Service Workorder report template





    7. And what is in the Unit's Custom fields now able to show on the report



    Last edited by AyaNova Support; 08-13-2010 at 08:57 AM.
    AyaNova Sales & Support
    www.ayanova.com

  2. #2
    Join Date
    Aug 2005
    Posts
    2,753

    Another Example of using API Methods to display Client's Popup fields

    Another example, via a different sample report template in a different named band (Detail instead of Detail1) and calling a different field from a client record - the Popup Notes field

    Don't forget to use the api.ayanova.com to obtain specific datafield names.

    API script popup Sample Client Claim Receipt.zip
    AyaNova Sales & Support
    www.ayanova.com

Posting Permissions

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