I tend to agree with the other responses that there may be a better way to address you need. But, assuming that you want what you expressed, here is a solution.
This includes the scriptConfig so you can deploy it from VS Code.
https://marketplace.visualstudio.com/items?itemName=sharptree.maximo-script-deploy
main();
function main(){
// safety checks to make sure we have an implicit Mbo object and that it is based on the WORKORDER object.
// also check that the ASSETNUM field is not null
if(typeof mbo !== 'undefined' && mbo!=null && mbo.isBasedOn("WORKORDER") && !mbo.isNull("ASSETNUM")){
// if the status has been changed and it is now COMP
if(mbo.getMboValue("STATUS").isModified() && mbo.getString("STATUS") == "COMP"){
// remove the previous Rich Text formatting tag
var assetNotes = mbo.getString("ASSET.SERVICENOTES_LONGDESCRIPTION").replaceAll("<!-- RICH TEXT -->", "");
var notes = "<p style=\"caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: Arial, Helvetica, sans-serif; font-size: 17.6px;\">"
+ "<strong>Work Order:</strong>" + mbo.getString("WONUM") + "</p>"
+ "<p style=\"caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: Arial, Helvetica, sans-serif; font-size: 17.6px;\">"
+ "<strong>WO Completion Date:</strong>" + mbo.getString("STATUSDATE") + "</p>"
+ "<p style=\"caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: Arial, Helvetica, sans-serif; font-size: 17.6px;\">"
+ "<strong>Service Notes:</strong></p><div>" + mbo.getString("SERVICENOTES_LONGDESCRIPTION") +"</div>"
+ "<!-- RICH TEXT -->"
mbo.setValue("ASSET.SERVICENOTES_LONGDESCRIPTION", assetNotes + "<p></p>" + notes);
}
}
}
var scriptConfig={
"autoscript": "WORKORDER.SERVICENOTES.COMP",
"description": "Copy service notes on completion.",
"version": "1.0.0",
"active": true,
"logLevel": "ERROR",
"scriptLaunchPoints": [
{
"launchPointName": "WORKORDER.SERVICENOTES.COMP",
"launchPointType": "OBJECT",
"active": true,
"description": "Copy service notes on completion.",
"objectName": "WORKORDER",
"save": true,
"add": true,
"update": true,
"delete": false,
"beforeSave": true
}
]
};
------------------------------
Jason VenHuizen
https://sharptree.iohttps://opqo.io------------------------------
Original Message:
Sent: Wed July 10, 2024 10:25 AM
From: mx pro
Subject: Appending Information from a Field in WO to a field in Asset
Hello all,
in Asset, we are adding a new field as ASSET.SERVICENOTES, with Long Description.
In Work Order, we are also adding a new as WORKORDER.SERVICENOTES, with Long Description.
The requirement is that when any Service Notes are entered in WORKORDER.SERVICENOTES and WO status is changed to COMP, then WONUM, the status change date and value of WORKORDER.SERVICENOTES is appended to the Long Description ASSET.SERVICENOTES at the top as per the following format.
Work Order: 123456
WO Completion Date: Status Change Date
Service Notes:
This is the Service Note
this same thing is done for every WO, where Service Notes is entered. If not entered, then this is not done.
Any idea how to do that?
I am of the view of an Automation Script...
If this is correct then can someone help with Automation Script... especially with Formatting...
Else... any other Idea
Note that having a field and displaying it on WORK tab of Asset... is not an option...
------------------------------
mx pro
------------------------------