Tuesday, 17 November 2020

Delete a Person from Person Groups (LIST VIEW QUERY) using Automation Script | Maximo

Requirement # 1:

How can we delete all persons from a list of PersonGroups except Group Default at once?

Requirement #2:

 How can we delete a specific person from all the listed person groups?

Solution:






  1. Create an Action Launch Point Script (let's say. DEL_PGTEAM)
  2. Open PERSONGR in application designer: 
    1. Create a Signature Option: DEL_PGTEAM., and choose "This is an action that must be invoked by the user in the UI" in the advance section
    2. Create Action with type Option with the same name as the signature option in step 1.
  3. Grant newly created signature option for specific Security Group.


Action Launch Point Script Details:

  • Name: DEL_PGTEAM
  • Object: PERSONGROUPTEAM
  • Launch Point Type: ACTION
  • Script body:
from psdi.server import MXServer
from psdi.mbo import MboConstants
from psdi.common.context import UIContext
mxServer = MXServer.getMXServer()
userInfo = mxServer.getUserInfo("maxadmin")
wclause = service.webclientsession().getCurrentApp().getResultsBean().getMboSet().getUserAndQbeWhere() 
pgWhere = wclause
pgSet = mxServer.getMboSet('PERSONGROUP', userInfo)
pgSet.setWhere(pgWhere)
pg = pgSet.moveFirst()
while pg: # Loop through the persongroups of list view one by one
    personGroupTeamSet = pg.getMboSet('ALLPERSONGROUPTEAM')
    personGroupTeam = personGroupTeamSet.moveFirst()
    while personGroupTeam: # Loop each person in a group
        if personGroupTeam.getBoolean("GROUPDEFAULT") == False:
            #uncomment below line and enter personid, if you want to delete specific person (requirement 2)
            #if personGroupTeam.getString("resppartygroup") in ('171061'): 
                personGroupTeam.delete() 
        personGroupTeam = personGroupTeamSet.moveNext()
    pgSet.save()
    pg = pgSet.moveNext()
service.error(":)","You are Done.")


No comments:

Post a Comment