Hi Sonali,
I assume that your logic is inside the def beforeCreateMboSet(ctx): and your code is inside OSIN.xxxxx script. You can also try writing your script inside beforeMboData method.
def beforeMboData(ctx):
woNumInMsg = ctx.getData().getCurrentData("WONUM")
woMboSet = ctx.getMboSet("WORKORDER")
woMboSet.setWhere("wonum ='" + woNumInMsg + "'")
if woMboSet.getMbo(0) is not None:
mxWonum = woMboSet.getMbo(0).getString("WONUM")
params = ["Work Order being duplicate(MXWONUM:"+mxWonum+" XXWONUM:"+woNumInMsg+")"]
ctx.error("WORKORDER", "errorduplicate",params)
Thanks,
Suren
------------------------------
Surendar Balasundaram
------------------------------
Original Message:
Sent: Thu June 13, 2024 08:22 AM
From: Sonali Pandharpatte
Subject: How can we throw a system error message using script for integration
Hello Steve,
While using ctx.error in python It is not giving me error for duplicate records.
I am creating workorder with same external reference id. Maximo is creating workorders , ideally it should display error message as duplicate record
if woMboSet.getMbo(0) is not None:
mxWombo = woMboSet.getMbo(0)
mxWonum = mxWombo.getString("WONUM")
params = ["Work Order being duplicate(MXWONUM:"+mxWonum+" SFWONUM:"+struc.getCurrentData("NG_SFWONUM")+")"]
ctx.error("NG_WORKORDER", "NG_SKIP",params)
Note: SFWONUM is external system Salesforce workorder Number
------------------------------
Sonali Pandharpatte
Original Message:
Sent: Wed May 24, 2023 08:02 AM
From: Steven Shull
Subject: How can we throw a system error message using script for integration
Your declaration of your function will look something like:
def beforeCreateMboSet(ctx):
ctx is an extension of the ScriptService class. You can call any of the methods available via the service variable using the name of the parameter like ctx in this case. I could call ctx.error("emx","myErrorMessage") for example.
------------------------------
Steven Shull
Original Message:
Sent: Tue May 23, 2023 09:32 AM
From: Akshay T
Subject: How can we throw a system error message using script for integration
Say we are creating a script for Object Structure Inbound processing and we are doing validations in beforeCreateMboset method, if we encounter a situation where in we want to throw an error message , how can we do that.
I tried service.error but it doesnt seem to work. Is there any way we can throw error message and not skip the transaction.
------------------------------
Akshay T
------------------------------
#Maximo
#MaximoIntegrationandScripting