0
0Like
Tweet 2
Deleting DOCLINKS with Automation ScriptingSachBalagopalan | Dec 22 | Visits (186)
Contributors Steve Hauptman Ted Lyons Mike Sielian John Cook Melody Bienfang
Introduction This post describes a technical solution that gives clients the flexibility to delete attacheddocuments (DOCLINKS) seamlessly and with ease By leveraging existing functionality in Maximo namely Escalationsand Automation Scripting you can purge attached documents from the location where the document physically lives Aselection criteria should be defined in an Escalation (eg STATUS = CLOSED) along with an Action which invokes aPython script (described in this post) that will physically delete the document from the server The Python script provided in this post is generic and can be applied to any object (Workorder Incident SR etc) Althoughwe recommend this script be used with an Escalation and an Action launch point it can be used with other launch pointsas well In addition to deleting the document from the server the script will also cleanup the entries in the Doclinks andother related tables There will be no orphaned records lingering after the file is physically deleted The script addressesdirect attachments as well as attachments uploaded via Communication Templates and CommLog Disclaimer Finally before we get into the details please note that this solution should not be deployed directly into a productionenvironment before testing and making sure it fits the clients use case The script does not contain any business rules orany sort of validation It simply deletes the file and cleans the Doclink table It is up to the client to decide when to invokethe script by defining the appropriate escalation criteria and frequency
Python Codefrom psdicommonaction import ActionCustomClass
from javaio import Filefrom javarmi import RemoteExceptionfrom psdimbo import from psdimbo import MboConstantsfrom psdiutil import MXExceptionfrom psdiappdoclink import Docinfofrom psdiappdoclink import DocinfoSetfrom psdiappdoclink import DocinfoSetRemotefrom psdiappdoclink import DoclinksSetRemotefrom javalang import SecurityExceptionfrom psdiserver import MXServerimport sys
My Blogs Public Blogs My UpdatesSearchThis Blog
anywhere apps
escalation installationshymanagermaximo+76 maximo76
mobile mobility
Log in
to participate
About this blogWelcome to the AssetManagement Blog where youcan read the perspectives fromAsset Management experts This
Blog provides technical insights into theMaximo product solutions
Related posts
Installing Maximo 7UpdatedDec 22 1 0
Configuring apps forUpdatedDec 19 0 0
Installing Maximo 7UpdatedDec 22 1 0
Installing Maximo 7UpdatedDec 22 1 0
PowerAdm shy Python ToUpdatedDec 15 0 0
Links
Manually install and configure
Recent tweets
Follow ServMgmtConnect
Share
Sign in (or register)EnglishIBM
Technical topics Evaluation software Community Events Search developerWorks
My home Forums Blogs Communities Profiles Podcasts Wikis Activities IBM Champion program
COMMENT function to check if the doclink owner is a commlog or the main mbodef isCommLogOwner(doclink) ownertable = doclinkgetString(OWNERTABLE) print( OWNERTABLE +ownertable) if (ownertable) == COMMLOG return True return False
COMMENT function to delete the commlog doc physical file from the serverdef deletecommlogfilefromserver(docinfo)
docinfoid = docinfogetString(DOCINFOID) commlogdocsSet = MXServergetMXServer()getMboSet(COMMLOGDOCS docinfogetUserInfo()) commlogdocsSetsetWhere(DOCINFOID = +docinfoid+) commlogdocsSetreset()
print( DOCINFOID +docinfoid)
k = 0 commlogdoc = commlogdocsSetgetMbo(k) while (commlogdoc is not None) urlname = commlogdocgetString(URLNAME) deleteCfile = File(urlname) if(deleteCfileexists()) deleteCfiledelete() k = k+1 commlogdocdelete(MboConstantsNOACCESSCHECK) commlogdoc = commlogdocsSetgetMbo(k) commlogdocsSetdeleteAll(MboConstantsNOACCESSCHECK) commlogdocsSetsave(MboConstantsNOACCESSCHECK)
COMMENT function to delete the physical file from the serverdef deletefilefromserver(docinfo) urlname = docinfogetString(URLNAME) deletefile = File(urlname) if (deletefileexists()) print( Deleting file +urlname) deletefiledelete() print( File Deleted +urlname)
print Starting doclink delete
COMMENT from the Action MBO get the associated DoclinksSet based on the DOCLINKS relationshipdoclinksSet = mbogetMboSet(DOCLINKS)
if doclinksSet is not None i = 0 doclink = doclinksSetgetMbo(i) while (doclink = None) docinfoSet = doclinkgetMboSet(DOCINFO) if (docinfoSet is not None) j=0 docinfo = docinfoSetgetMbo(j) while (docinfo = None) if (isCommLogOwner(doclink)) deletecommlogfilefromserver(docinfo) else print( deletefilefromserver ) deletefilefromserver(docinfo) docinfodelete(MboConstantsNOACCESSCHECK) doclinkdelete(MboConstantsNOACCESSCHECK) j=j+1 docinfo = docinfoSetgetMbo(j) i=i+1 doclink = doclinksSetgetMbo(i)
Defining the Automation Script in the Automation Scripts Application Launch the Automation Script App and 1) Select Script with Action Launch Point shy youre going to be launching this script from an Action
2) Give it a name like DOCLINKS or something and note it down because youll need it when defining the Action in thenext step I used Workorder but you can set the Object to whatever is applicable
3) Set the fields as defined in the image below
4) Cut and paste the python code from the Code section in blue above
Define an Action in the Actions ApplicationGo to the Actions app and create a new action like this
The ParameterAttribute has to the be the same name as the Script name created in the step above
Define the Escalation
Go to the Escalation Application and define an Escalation with the appropriate condition and reference points that fit youruse case Here is a link on how to set up an escalation
Conclusion
This is a pretty powerful solution for those seeking to delete DOCLINK attachments within Maximo There is no need todeploy any compiled code or bring down the server to take advantage of this solution
Tags scripting attached docs escalation python attacheddocs maximo tpae doclinks
Add a Comment More Actions Comments (0)
About
Help
Contact us
Submit content
Feeds
Newsletters
Report abuse
Terms of use
Third party notice
IBM privacy
IBM accessibility
Faculty
Students
Business Partners
Add a Comment More Actions
Previous Entry Main Next Entry
Follow
Like
COMMENT function to check if the doclink owner is a commlog or the main mbodef isCommLogOwner(doclink) ownertable = doclinkgetString(OWNERTABLE) print( OWNERTABLE +ownertable) if (ownertable) == COMMLOG return True return False
COMMENT function to delete the commlog doc physical file from the serverdef deletecommlogfilefromserver(docinfo)
docinfoid = docinfogetString(DOCINFOID) commlogdocsSet = MXServergetMXServer()getMboSet(COMMLOGDOCS docinfogetUserInfo()) commlogdocsSetsetWhere(DOCINFOID = +docinfoid+) commlogdocsSetreset()
print( DOCINFOID +docinfoid)
k = 0 commlogdoc = commlogdocsSetgetMbo(k) while (commlogdoc is not None) urlname = commlogdocgetString(URLNAME) deleteCfile = File(urlname) if(deleteCfileexists()) deleteCfiledelete() k = k+1 commlogdocdelete(MboConstantsNOACCESSCHECK) commlogdoc = commlogdocsSetgetMbo(k) commlogdocsSetdeleteAll(MboConstantsNOACCESSCHECK) commlogdocsSetsave(MboConstantsNOACCESSCHECK)
COMMENT function to delete the physical file from the serverdef deletefilefromserver(docinfo) urlname = docinfogetString(URLNAME) deletefile = File(urlname) if (deletefileexists()) print( Deleting file +urlname) deletefiledelete() print( File Deleted +urlname)
print Starting doclink delete
COMMENT from the Action MBO get the associated DoclinksSet based on the DOCLINKS relationshipdoclinksSet = mbogetMboSet(DOCLINKS)
if doclinksSet is not None i = 0 doclink = doclinksSetgetMbo(i) while (doclink = None) docinfoSet = doclinkgetMboSet(DOCINFO) if (docinfoSet is not None) j=0 docinfo = docinfoSetgetMbo(j) while (docinfo = None) if (isCommLogOwner(doclink)) deletecommlogfilefromserver(docinfo) else print( deletefilefromserver ) deletefilefromserver(docinfo) docinfodelete(MboConstantsNOACCESSCHECK) doclinkdelete(MboConstantsNOACCESSCHECK) j=j+1 docinfo = docinfoSetgetMbo(j) i=i+1 doclink = doclinksSetgetMbo(i)
Defining the Automation Script in the Automation Scripts Application Launch the Automation Script App and 1) Select Script with Action Launch Point shy youre going to be launching this script from an Action
2) Give it a name like DOCLINKS or something and note it down because youll need it when defining the Action in thenext step I used Workorder but you can set the Object to whatever is applicable
3) Set the fields as defined in the image below
4) Cut and paste the python code from the Code section in blue above
Define an Action in the Actions ApplicationGo to the Actions app and create a new action like this
The ParameterAttribute has to the be the same name as the Script name created in the step above
Define the Escalation
Go to the Escalation Application and define an Escalation with the appropriate condition and reference points that fit youruse case Here is a link on how to set up an escalation
Conclusion
This is a pretty powerful solution for those seeking to delete DOCLINK attachments within Maximo There is no need todeploy any compiled code or bring down the server to take advantage of this solution
Tags scripting attached docs escalation python attacheddocs maximo tpae doclinks
Add a Comment More Actions Comments (0)
About
Help
Contact us
Submit content
Feeds
Newsletters
Report abuse
Terms of use
Third party notice
IBM privacy
IBM accessibility
Faculty
Students
Business Partners
Add a Comment More Actions
Previous Entry Main Next Entry
Follow
Like
2) Give it a name like DOCLINKS or something and note it down because youll need it when defining the Action in thenext step I used Workorder but you can set the Object to whatever is applicable
3) Set the fields as defined in the image below
4) Cut and paste the python code from the Code section in blue above
Define an Action in the Actions ApplicationGo to the Actions app and create a new action like this
The ParameterAttribute has to the be the same name as the Script name created in the step above
Define the Escalation
Go to the Escalation Application and define an Escalation with the appropriate condition and reference points that fit youruse case Here is a link on how to set up an escalation
Conclusion
This is a pretty powerful solution for those seeking to delete DOCLINK attachments within Maximo There is no need todeploy any compiled code or bring down the server to take advantage of this solution
Tags scripting attached docs escalation python attacheddocs maximo tpae doclinks
Add a Comment More Actions Comments (0)
About
Help
Contact us
Submit content
Feeds
Newsletters
Report abuse
Terms of use
Third party notice
IBM privacy
IBM accessibility
Faculty
Students
Business Partners
Add a Comment More Actions
Previous Entry Main Next Entry
Follow
Like
4) Cut and paste the python code from the Code section in blue above
Define an Action in the Actions ApplicationGo to the Actions app and create a new action like this
The ParameterAttribute has to the be the same name as the Script name created in the step above
Define the Escalation
Go to the Escalation Application and define an Escalation with the appropriate condition and reference points that fit youruse case Here is a link on how to set up an escalation
Conclusion
This is a pretty powerful solution for those seeking to delete DOCLINK attachments within Maximo There is no need todeploy any compiled code or bring down the server to take advantage of this solution
Tags scripting attached docs escalation python attacheddocs maximo tpae doclinks
Add a Comment More Actions Comments (0)
About
Help
Contact us
Submit content
Feeds
Newsletters
Report abuse
Terms of use
Third party notice
IBM privacy
IBM accessibility
Faculty
Students
Business Partners
Add a Comment More Actions
Previous Entry Main Next Entry
Follow
Like
Add a Comment More Actions Comments (0)
About
Help
Contact us
Submit content
Feeds
Newsletters
Report abuse
Terms of use
Third party notice
IBM privacy
IBM accessibility
Faculty
Students
Business Partners
Add a Comment More Actions
Previous Entry Main Next Entry
Follow
Like