Sunday, 14 November 2021

Confirmation dialog before Deleting PR Item, and Save It In Worklog | Maximo

Add a confirmation dialog before deleting any line in PR application. So that user will have to enter the reason of deletion and it will be saved in worklog with all the related details like who deleted, reason of deletion, what was the item number and quantity at the time of deletion.

1. add one non-persistent attribute let's say NP_REASON in the PR object.

2. Make/add a dialog in PR.XML, add NP_REASON attribute 

<dialog id="deletedialog" label="deletedialog">
<section id="1567883350896">
<sectionrow id="1567883359616">
<sectioncol id="1567883366027">
<statictext align="left" id="1597323707588" label="Are you sure, you want to delete this line?"/>
<textbox dataattribute="PRNUM" id="1567883419910" inputmode="readonly"/>
<textbox dataattribute="iTEMNUM" id="1597321688221" inputmode="readonly"/>
<textbox dataattribute="NP_REASON" id="1567892172806" inputmode="required"/>
</sectioncol>
<sectioncol id="1567883367821"/>
<sectioncol id="15678833596162"/>
</sectionrow>
</section>
<buttongroup id="mydialog_2">
<pushbutton default="true" id="mydialog_2_1" label="OK" mxevent="dialogok"/>
<pushbutton id="mydialog_2_2" label="Cancel" mxevent="dialogcancel"/>
</buttongroup>
</dialog>

3. In PRLINE tab using application designer, edit the delete button properties and modify the event property to the newly created dialog (deletedialog) as below:

event: deletedialog

4. Write an ALP automation script on PR.NP_REASON attribute, the body is as below:


vWORKLOG = mbo.getMboSet("PR.WORKLOG")
line = vWORKLOG.add()
line.setValue("LOGTYPE","CLIENTNOTE")
line.setValue("DESCRIPTION",str("Item:")+mbo.getString("itemnum")+str(" Qty:") + mbo.getString("ORDERQTY") +str(" UnitCost:") + str(mbo.getDouble("unitcost"))+str(" Reason:") + mbo.getString("NP_REASON"))
line.setValue("SITEID","KAUST")
line.setValue("RECORDKEY",mbo.getString("prnum"),2L)
line.setValue("CLASS","PR",2L)
mbo.delete()
mbo.save()



  

1 comment: