I've created an Escalation on the PO object that executes an Action that launch an Automation Script. This AutoScript modifies a couple of attributes on the PO and also creates two related MboSets on the fly and adds two new, child Objects (one a custom object and one is the DOCLINKS object). With these two related MboSets, the AutoScript calls MboSet.add() and then it fills in attributes on the newly added Mbos.
At the end of the AutoScript, it logs out: mbo.isModified(), mboSet1.count(), mboSet1.count() and the logging confirms that the mbo in the script (which is the PO object picked up by the Escalation) is modified and, also, mboSet1.count is 1 and mboSet2.count also indicates 1. These are the new Mbo objects, one in each set.
The AutoScript completes execution without error and the Escalation records no error. However, afterwards, I pull up the PO in the PO app and find that the attributes that should have been modified are still not modified and the two related MboSets never saved to the database any new records.
What could possibly explain the successful execution during the Escalation Action, but nothing actually saved to the database?
Allow me to clarify what I've noted above when I say "creates related MboSets on the fly". I mean that I called: set1 = mbo.getMboSet('$_DOCLINKS_$', 'DOCLINKS', '1 = 2'). Then, I call set1.add(). I'm expecting the automatic Save on the PO (by the Escalation) to cause all related MboSets in memory that are marked as modified to also get saved.
Here is a summary of the code in question:
# ...
# Create custom record KAES_POECOMSTATUS
pesSet = poMbo.getMboSet('$_PES_$', 'KAES_POECOMSTATUS', '1 = 2')
pesSet.reset()
pesMbo = pesSet.add(MboConstants.NOACCESSCHECK)
# ... set values on pesMbo
# Create DOCLINKS/DOCINFO attachment to PO
logger.debug('Creating DOCLINKS data...')
docLinksSet = mbo.getMboSet('$_DOCLINKS_$', 'DOCLINKS', '1 = 2')
docLinksSet.reset()
docLinksMbo = docLinksSet.add(MboConstants.NOACCESSCHECK)
docLinksMbo.setValue('URLTYPE', 'FILE')
docLinksMbo.setValue('URLNAME', outputFileName)
docLinksMbo.setValue('NEWURLNAME', outputFileName)
docLinksMbo.setValue('DOCTYPE', attachFolder)
docLinksMbo.setValue('ADDINFO', True)
docLinksMbo.setValue('DESCRIPTION', attachDesc)
# ...
logger.debug('mbo isModified: %s' % (str(mbo.isModified())))
s1 = mbo.getMboSet('$_DOCLINKS_$', 'DOCLINKS', '1 = 2')
s2 = mbo.getMboSet('$_PES_$', 'KAES_POECOMSTATUS', '1 = 2')
logger.debug('mboSet Count ($_DOCLINKS_$): %d' % (s1.count()))
logger.debug('mboSet Count ($_PES_$): %d' % (s2.count()))
# End of Script
And here is a snippet of the server logs for the last few logger statements (indicates there are modifications and new objects ready to save in memory):
29 Jun 2023 18:30:58:744 [DEBUG] getting logger
29 Jun 2023 18:30:58:744 [DEBUG] getting mbo
29 Jun 2023 18:30:58:744 [DEBUG] [K_EMAILPO_TOVENDOR:EMAILPO2VEND:POID 952610] mbo isModified: True
29 Jun 2023 18:30:58:744 [DEBUG] getting mbo
29 Jun 2023 18:30:58:744 [DEBUG] getting mbo
29 Jun 2023 18:30:58:744 [DEBUG] getting logger
29 Jun 2023 18:30:58:744 [DEBUG] getting s1
29 Jun 2023 18:30:58:744 [DEBUG] [K_EMAILPO_TOVENDOR:EMAILPO2VEND:POID 952610] mboSet Count ($_DOCLINKS_$): 1
29 Jun 2023 18:30:58:744 [DEBUG] getting logger
29 Jun 2023 18:30:58:744 [DEBUG] getting s2
29 Jun 2023 18:30:58:744 [DEBUG] [K_EMAILPO_TOVENDOR:EMAILPO2VEND:POID 952610] mboSet Count ($_PES_$): 1
29 Jun 2023 18:30:58:744 [DEBUG] execution completed for cached compiled script K_EMAILPO_TOVENDOR for launch point EMAILPO2VEND
...
29 Jun 2023 18:30:58:744 [DEBUG] The total time taken to execute the K_EMAILPO_TOVENDOR script for the EMAILPO2VEND launch point is +4479 ms.
29 Jun 2023 18:30:58:744 [DEBUG] ScriptAction call ended for scriptName K_EMAILPO_TOVENDOR and launch point EMAILPO2VEND
Please let me know if I need to clarify my question.