News
Abstract
The OSACTION.MXAPIINSPRESULT.CREATEWO automation script (provided by IBM) is intended for demo and test usage only. It cannot be used in a production environment. The script is compatible with the Inspections Work Centers, which were deprecated. The script is not compatible with IBM Maximo Mobile Inspections.
Content
The OSACTION.MXAPIINSPRESULT.CREATEWO automation script will be discontinued in IBM Maximo Mobile 8.11. Upgraded environments will continue to have this legacy script, so existing users are not affected by this change. New installations will not have the script.
You can execute your own custom automation scripts on mobile inspections, but IBM does not provide support for
the scripts. To continue using the OSACTION.MXAPIINSPRESULT.CREATEWO automation script in your demo/test environment, you need to duplicate it and create a new script that points to the new object structure in the script name. It must be renamed to OSACTION.MXAPIINSPECTIONRES.CREATEWO. Keep the same code to maintain the same functionality.
As an alternative, the following script creates one work order for the inspection form, and adds one task for each response tagged with "Require action."
As an alternative, the following script creates one work order for the inspection form, and adds one task for each response tagged with "Require action."
1. Navigate to the Automation Scripts application in IBM Maximo Manage.
2. Click Create > Script. Populate fields as follows:
- Script: OSACTION.MXAPIINSPECTIONRES.CREATEWOWTASKS
- Script Description: Create WO for inspection items that require action
- Script language: jython
In the script code section, copy and paste the following code, then click Save.
print "=============== EXECUTING CREATE WO SCRIPT ===============";
planned = False;
if (mbo.getString("REFERENCEOBJECT")=="WORKORDER" or mbo.getString("REFERENCEOBJECT")=="WOACTIVITY") :
planned = True;
else:
planned = False;
# iterate through the responses
resultSet = mbo.getMboSet("INSPFIELDRESULT");
for i in range(0,resultSet.count()):
currentResult = resultSet.getMbo(i);
# on the current response, check if it requires action (relationship INSPFIELDRESULTACT search on field options if the current response requires action)
requireActionSet = currentResult.getMboSet("INSPFIELDOPTIONACT");
requireAction=False;
if requireActionSet.count()>0:
requireAction=True;
if currentResult.getString("numresponse") is not None and currentResult.getBoolean("actionrequired")==True:
requireAction=True;
multiChoiceResponse = currentResult.getMboSet("INSPFIELDRESULTSELECTION");
if currentResult.getString("txtresponse") is None and currentResult.getString("numresponse") is None and multiChoiceResponse.count() > 0 and currentResult.getBoolean("actionrequired")==True:
requireAction=True;
if requireAction:
# for planned (with WO) inspections that does not have any follow up actions to its results yet
questionDetailSet = currentResult.getMboSet("INSPQUESTION");
desc = questionDetailSet.getMbo(0).getString("description") + " = " + currentResult.getString("TXTRESPONSE");
#commented code to not generate a workorder per answered question
#if (planned and currentResult.getString("FUPOBJECT")==""):
#This will create your follow up WO, it can be part of the WO/Task itself or you can relate them to the ParentWO that contains all results
#This code is comment , to fix issue Create
#if mbo.getString("PARENT") is not None:
#woSet = mbo.getMboSet("PARENTWO");
#else:
#woSet = mbo.getMboSet("WORKORDER");
#wo = woSet.getMbo(0);
# create a follow up work order
#newWO = wo.createWorkorder();
#set WO desc based on the question response
#newWOSet = mbo.getMboSet("$NewWO","WORKORDER","wonum='" + newWO.getString("wonum") + "' and siteid= '" + newWO.getString("siteid") + "'");
#newWOSet.getMbo(0).setValue("description",desc);
#newWOSet.getMbo(0).setValue("location",mbo.getString("location"));
#newWOSet.getMbo(0).setValue("assetnum",mbo.getString("asset"));
#currentResult.setValue("FUPOBJECT","WORKORDER");
#currentResult.setValue("FUPOBJECTID",newWO.getString("wonum"));
#currentResult.setValue("DISPLAYMESSAGE","Workorder " + str(newWO.getString("wonum")) + " created");
#newWOSet.save();
# if does not have a planning WO, will create a new WO and include each individual question that require action as a task
if (currentResult.getString("FUPOBJECT")==""):
woSet = mbo.getMboSet("WORKORDER");
# if there is already a WO created for the result, just skip
if mbo.getString("FUPOBJECT")=="":
newWO = woSet.add();
newWO.setValue("Description","Follow Up Work Order for Inspection " + str(mbo.getString("resultnum")));
newWO.setValue("location",mbo.getString("location"));
newWO.setValue("assetnum",mbo.getString("asset"));
mbo.setValue("FUPOBJECT","WORKORDER");
mbo.setValue("FUPOBJECTID",newWO.getString("wonum"));
mbo.setValue("DISPLAYMESSAGE","Workorder " + str(newWO.getString("wonum")) + " created");
print "Created WO " + str(newWO.getString("wonum"));
woSet.save();
woSet = mbo.getMboSet("FUPWORKORDER");
newTask = woSet.getMbo(0).getMboSet("WOACTIVITY").add();
newTask.setValue("PARENT",mbo.getString("FUPOBJECTID"));
print "Created Task " + str(newTask.getString("taskid"));
newTask.setValue("description",desc);
currentResult.setValue("FUPOBJECT","WORKORDER");
currentResult.setValue("FUPOBJECTID",newTask.getString("wonum"));
currentResult.setValue("DISPLAYMESSAGE","Work Order " + mbo.getString("FUPOBJECTID") + " Task " + str(newTask.getString("taskid")) + " created");
woSet.save();
resultSet.save();
print "=============== END CREATE WO SCRIPT ===============";
planned = False;
if (mbo.getString("REFERENCEOBJECT")=="WORKORDER" or mbo.getString("REFERENCEOBJECT")=="WOACTIVITY") :
planned = True;
else:
planned = False;
# iterate through the responses
resultSet = mbo.getMboSet("INSPFIELDRESULT");
for i in range(0,resultSet.count()):
currentResult = resultSet.getMbo(i);
# on the current response, check if it requires action (relationship INSPFIELDRESULTACT search on field options if the current response requires action)
requireActionSet = currentResult.getMboSet("INSPFIELDOPTIONACT");
requireAction=False;
if requireActionSet.count()>0:
requireAction=True;
if currentResult.getString("numresponse") is not None and currentResult.getBoolean("actionrequired")==True:
requireAction=True;
multiChoiceResponse = currentResult.getMboSet("INSPFIELDRESULTSELECTION");
if currentResult.getString("txtresponse") is None and currentResult.getString("numresponse") is None and multiChoiceResponse.count() > 0 and currentResult.getBoolean("actionrequired")==True:
requireAction=True;
if requireAction:
# for planned (with WO) inspections that does not have any follow up actions to its results yet
questionDetailSet = currentResult.getMboSet("INSPQUESTION");
desc = questionDetailSet.getMbo(0).getString("description") + " = " + currentResult.getString("TXTRESPONSE");
#commented code to not generate a workorder per answered question
#if (planned and currentResult.getString("FUPOBJECT")==""):
#This will create your follow up WO, it can be part of the WO/Task itself or you can relate them to the ParentWO that contains all results
#This code is comment , to fix issue Create
#if mbo.getString("PARENT") is not None:
#woSet = mbo.getMboSet("PARENTWO");
#else:
#woSet = mbo.getMboSet("WORKORDER");
#wo = woSet.getMbo(0);
# create a follow up work order
#newWO = wo.createWorkorder();
#set WO desc based on the question response
#newWOSet = mbo.getMboSet("$NewWO","WORKORDER","wonum='" + newWO.getString("wonum") + "' and siteid= '" + newWO.getString("siteid") + "'");
#newWOSet.getMbo(0).setValue("description",desc);
#newWOSet.getMbo(0).setValue("location",mbo.getString("location"));
#newWOSet.getMbo(0).setValue("assetnum",mbo.getString("asset"));
#currentResult.setValue("FUPOBJECT","WORKORDER");
#currentResult.setValue("FUPOBJECTID",newWO.getString("wonum"));
#currentResult.setValue("DISPLAYMESSAGE","Workorder " + str(newWO.getString("wonum")) + " created");
#newWOSet.save();
# if does not have a planning WO, will create a new WO and include each individual question that require action as a task
if (currentResult.getString("FUPOBJECT")==""):
woSet = mbo.getMboSet("WORKORDER");
# if there is already a WO created for the result, just skip
if mbo.getString("FUPOBJECT")=="":
newWO = woSet.add();
newWO.setValue("Description","Follow Up Work Order for Inspection " + str(mbo.getString("resultnum")));
newWO.setValue("location",mbo.getString("location"));
newWO.setValue("assetnum",mbo.getString("asset"));
mbo.setValue("FUPOBJECT","WORKORDER");
mbo.setValue("FUPOBJECTID",newWO.getString("wonum"));
mbo.setValue("DISPLAYMESSAGE","Workorder " + str(newWO.getString("wonum")) + " created");
print "Created WO " + str(newWO.getString("wonum"));
woSet.save();
woSet = mbo.getMboSet("FUPWORKORDER");
newTask = woSet.getMbo(0).getMboSet("WOACTIVITY").add();
newTask.setValue("PARENT",mbo.getString("FUPOBJECTID"));
print "Created Task " + str(newTask.getString("taskid"));
newTask.setValue("description",desc);
currentResult.setValue("FUPOBJECT","WORKORDER");
currentResult.setValue("FUPOBJECTID",newTask.getString("wonum"));
currentResult.setValue("DISPLAYMESSAGE","Work Order " + mbo.getString("FUPOBJECTID") + " Task " + str(newTask.getString("taskid")) + " created");
woSet.save();
resultSet.save();
print "=============== END CREATE WO SCRIPT ===============";
[{"Type":"MASTER","Line of Business":{"code":"LOB59","label":"Sustainability Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSRHPA","label":"IBM Maximo Application Suite"},"ARM Category":[{"code":"a8m3p000000hAgaAAE","label":"Maximo Application Suite-\u003EMAS Applications-\u003EMobile"}],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]
Was this topic helpful?
Document Information
Modified date:
15 June 2023
UID
ibm17004275