Results 1 to 2 of 2

Thread: Previous Workorder Number

  1. #1
    Join Date
    May 2007
    Posts
    36

    Previous Workorder Number

    Hi,

    I wondered if there was a way of getting the previous workorder associated with a unit without having to use unit.History and then stripping the text out. The ultimate aim is when the user has a workorder open they run a report which extracts pertinetent information for the current work order plus the service notes from last time. Realise that can right click the serial number form the service screen and then look at previous jobs and run a report that way, however attemtping to come up with a more elegant solution !!

  2. #2
    Join Date
    Aug 2005
    Posts
    186

    Re: Previous Workorder Number

    Hi Martin, you could use the workoder service item list filtered by the Unit Id, just like you would do manually in the UI grid (though I don't know if that's an improvement over scraping the unit history), something like this:


    Guid unitId = new Guid("{FC46F50E-7944-4B40-B307-59EE34145BD5}");

    WorkorderServiceItemList wisl = WorkorderServiceItemList.GetList("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
    "<GRIDCRITERIA> \r\n" +
    " <COLUMNITEM CM=\"aWorkorderService.aServiceDate\" UI=\"LT_WorkorderService_Label_ServiceDate\" PIN=\"0\" WIDTH=\"112\" SORT=\"ASC\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorderService.aServiceNumber\" UI=\"LT_O_Workorder\" PIN=\"0\" WIDTH=\"100\" /> \r\n" +
    " <COLUMNITEM CM=\"aUnit.aSerial\" UI=\"LT_Unit_Label_Serial\" PIN=\"0\" WIDTH=\"292\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorderItemStatus.aName\" UI=\"LT_WorkorderItem_Label_WorkorderStatusID\" PIN=\"0\" WIDTH=\"158\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorder.aServiceCompleted\" UI=\"LT_Workorder_Label_ServiceCompleted\" PIN=\"0\" WIDTH=\"143\" /> \r\n" +
    " <COLUMNITEM CM=\"aClient.aName\" UI=\"LT_O_Client\" PIN=\"0\" WIDTH=\"76\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorder.aOnsite\" UI=\"LT_Workorder_Label_Onsite\" PIN=\"0\" WIDTH=\"80\" /> \r\n" +
    " <COLUMNITEM CM=\"aPriority.aName\" UI=\"LT_WorkorderItem_Label_PriorityID\" PIN=\"0\" WIDTH=\"83\" /> \r\n" +
    " <COLUMNITEM CM=\"aUnitServiceType.aName\" UI=\"LT_O_UnitServiceType\" PIN=\"0\" WIDTH=\"131\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorderCategory.aName\" UI=\"LT_O_WorkorderCategory\" PIN=\"0\" WIDTH=\"149\" /> \r\n" +
    " <COLUMNITEM CM=\"aDispatchZone.aName\" UI=\"LT_O_DispatchZone\" PIN=\"0\" WIDTH=\"120\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorderItem.aSummary\" UI=\"LT_WorkorderItem_Label_Summary\" PIN=\"0\" WIDTH=\"121\" /> \r\n" +
    " <COLUMNITEM CM=\"aWorkorderItemType.aName\" UI=\"LT_WorkorderItem_Label_TypeID\" PIN=\"0\" WIDTH=\"153\" /> \r\n" +
    " <COLUMNITEM CM=\"aUnitModel.aName\" UI=\"LT_O_UnitModel\" PIN=\"0\" WIDTH=\"101\" /> \r\n" +
    " <COLUMNITEM CM=\"aUnitMeterReading.aMeter\" UI=\"LT_UnitMeterReading_Label_Meter\" PIN=\"0\" WIDTH=\"145\" /> \r\n" +
    " <WHEREITEMGROUP GROUPLOGICALOPERATOR=\"And\" UI=\"LT_Unit_Label_Serial\"> \r\n" +
    " <WHEREITEM COMPAREOPERATOR=\"Equals\" CM=\"aWorkorderItem.aUnitID\" UICOMPAREVALUE=\"\" TYPE=\"System.Guid\" COMPAREVALUE=\"{" + unitId.ToString().ToUpperInvariant() + "}\" /> \r\n" +
    "</WHEREITEMGROUP> \r\n" +
    "</GRIDCRITERIA> ");
    MessageBox.Show(wisl.Count.ToString());

    You can iterate them like this: foreach(WorkorderServiceItemList.WorkorderServiceItemListInfo i in wisl) { i.oneOfManyFieldsHere; //etc}

    You can build a starter grid criteria in the UI then get the actual code to use by using the ctrl-alt-g command from the main grid. Remember this is Items so there could be dupes of the same workorder etc.

Posting Permissions

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