Create a work order and add labor hours with Maximo REST

You can already create a new work order with REST but it’s useless if you can’t add labor hours to it right? This tutorial will show you how to setup the MXWO object structure to be able to add LABTRANS records at the same time you create a work order. You can now create a work order with a location and description and add the same time add labor hours to it.

The process is pretty much the same as you did for creating a work order with REST but we have to change the MXWO object structure to work with the LABTRANS object. You can always create your own object but we can just modify the existing one for now.

First to go Object Structures and open the MXWO record. You will see there is only one WORKORDER object listed. We need to add the LABTRANS object like so:

MXWO Object Structure

Once you have added that, we need to change the inbound restrictions on this object. Click on Select Action -> Inbound Setting Restrictions. You will the STATUS field is restricted to change it, click on the ‘Override’ and then click on ‘Restricted’ checkboxes. Next, hit OK and generate schema by click on Select Action -> Generate Schema/View XML.

Now we are ready to POST data to this object. It’s the same form we used in the last tutorial but we added a few fields.

<html>
<body>
<form name="input" action="http://maximoserver/maxrest/rest/os/MXWO?_lid=maxadmin&_lpwd=maxadmin" method="POST">
    LOCATION    <input name="LOCATION" value="SHIPPING" type="text"> <p/>
    DESCRIPTION <input name="DESCRIPTION" value="Test Rest" type="text"> <p/>
    STATUS      <input name="STATUS" value="APPR" type="text"><p/> 
    SITEID      <input name="SITEID" value="BEDFORD" type="text"> <p/>
    ORGID       <input name="ORGID" value="EAGLENA" type="text"> <p/>

    LABORCODE   <input name="LABTRANS.ID1.LABORCODE" value="SILIKI" type="text"><p/>
    CRAFT       <input name="LABTRANS.ID1.CRAFT" value="MECH" type="text"><p/>
    REGULARHRS  <input name="LABTRANS.ID1.REGULARHRS" value="2.0" type="text"><p/> 

    <input type="submit" value="Submit">
</form>
</body>

You can see in this form, we added the STATUS field because you can’t add labor hours to a work order that is WAPPR and that is the default status when creating a new one so we have to change it. Then I added LABORCODE, CRAFT and REGULARHRS fields that are associated with the LABTRANS child object. These are the minimum fields that are required for the LABTRANS to be added. You can see something that might look odd and that is the “ID1” in the name attribute. This is needed to identify which fields are associated with that record. For example, you are adding one LABTRANS record, but you are using the LABORCODE, CRAFT and REGULARHRS fields on that one record. This is useful because you can add as many LABTRANS records as you want.

Here is an example where you can add two LABTRANS records in the same form:

<html>
<body>
<form name="input" action="http://maximoserver/maxrest/rest/os/MXWO?_lid=maxadmin&_lpwd=maxadmin" method="POST">
    LOCATION    <input name="LOCATION" value="SHIPPING" type="text"> <p/>
    DESCRIPTION <input name="DESCRIPTION" value="Test Rest" type="text"> <p/>
    STATUS      <input name="STATUS" value="APPR" type="text"><p/> 
    SITEID      <input name="SITEID" value="BEDFORD" type="text"> <p/>
    ORGID       <input name="ORGID" value="EAGLENA" type="text"> <p/>

    LABORCODE   <input name="LABTRANS.ID1.LABORCODE" value="SILIKI" type="text"><p/>
    CRAFT       <input name="LABTRANS.ID1.CRAFT" value="MECH" type="text"><p/>
    REGULARHRS  <input name="LABTRANS.ID1.REGULARHRS" value="2.0" type="text"><p/> 

    LABORCODE   <input name="LABTRANS.ID2.LABORCODE" value="SILIKI" type="text"><p/>
    CRAFT       <input name="LABTRANS.ID2.CRAFT" value="MECH" type="text"><p/>
    REGULARHRS  <input name="LABTRANS.ID2.REGULARHRS" value="2.0" type="text"><p/> 

    <input type="submit" value="Submit">
</form>
</body>

Notice that the second record is marked with “ID2”. This will create a new work order, change the status to APPR and then add two labor records to the work order.

Series Navigation
This entry is part [part not set] of 7 in the series Maximo REST API

Did You Know...

As Maximo Experts, we have developed several add-on products for Maximo that mobilize the work force, simplifies assignments, provides ad-hoc reporting capabilities and facilitates the seamless integration of Service Requests into Maximo.

Check out our products by clicking on the following links: EZMaxMobile, EZMaxPlanner and EZMaxRequest.

Find Out More

Leave a Reply