JohnDanter2
VIP Member
Hi all
I just thought I'd share a simple bit of Groovy which can read the output of a BSFN step and concatonate all the usual error info into one easily readable line (great for smaller mobile devices)
I create 2 new output variables RRDResult and RRDErrorText (you can call yours whatever you like)
So what this does is convert all this usual output stuff...
Into 1 output variable (scsInfo) when there is an error, like this
This code also sets output variable RRDResult to 200001 (and the error text will not be created) when all is ok and then 200003 when any error is detected
I hope you find this useful as I will now be copy pasting this into ALL my orchestrations going forward
Thanks
John
I just thought I'd share a simple bit of Groovy which can read the output of a BSFN step and concatonate all the usual error info into one easily readable line (great for smaller mobile devices)
I create 2 new output variables RRDResult and RRDErrorText (you can call yours whatever you like)
Code:
import groovy.json.JsonSlurper;
import groovy.json.JsonBuilder;
import com.oracle.e1.common.OrchestrationAttributes;
String main(OrchestrationAttributes orchAttr, String input)
{
def jsonIn = new JsonSlurper().parseText(input);
// modify jsonIn;
//Default reponse to be OK
jsonIn.RRDResult = "200001"
//if error detected set to 200003
if (jsonIn.continuedOnError!=null) {
//set the control variable RRDResult to be in error state
jsonIn.RRDResult='200003'
// Build error text string from object O, line number L, error code E and error text
jsonIn.RRDErrorText =
'O: '+jsonIn.ServiceRequest1.fileName+' L: '+jsonIn.ServiceRequest1.lineNumber+' E: '+jsonIn.ServiceRequest1.szerror +' '+jsonIn.ServiceRequest1.glossaryText
}
def jsonOut = new JsonBuilder(jsonIn).toString();
// orchAttr.writeWarn("custom log entry - warning");
// orchAttr.writeDebug("custom log entry - debug");
return jsonOut;
}
So what this does is convert all this usual output stuff...
Code:
{
"ServiceRequest1": {
"szerror": "0027",
"errorLevel": 1,
"alphaDescription": "Error: User Defined Code Error",
"glossaryText": "CAUSE . . . . The entered code was not found in the User Defined Codes.\nRESOLUTION. . Enter a valid code or place the cursor in the field in error\n and press 'F1' to display the valid values for the field.\n",
"fileName": "rtk_udvl.c",
"lineNumber": 597
},
"continuedOnError": [
{
"step": "RRD_N55APIRD_BSFN",
"message": {
"RRD_N55APIRD_BSFN": {
"szerror": "0027",
"errorLevel": 1,
"alphaDescription": "Error: User Defined Code Error",
"glossaryText": "CAUSE . . . . The entered code was not found in the User Defined Codes.\nRESOLUTION. . Enter a valid code or place the cursor in the field in error\n and press 'F1' to display the valid values for the field.\n",
"fileName": "rtk_udvl.c",
"lineNumber": 597
}
},
"timeStamp": "2023-03-16T12:02:18.435-0500",
"userDefinedErrorText": ""
}
],
Into 1 output variable (scsInfo) when there is an error, like this
Code:
"RRDResult": "200003",
"RRDErrorText": "O: rtk_udvl.c L: 597 E: 0027 CAUSE . . . . The entered code was not found in the User Defined Codes.\nRESOLUTION. . Enter a valid code or place the cursor in the field in error\n and press 'F1' to display the valid values for the field.\n",
This code also sets output variable RRDResult to 200001 (and the error text will not be created) when all is ok and then 200003 when any error is detected
I hope you find this useful as I will now be copy pasting this into ALL my orchestrations going forward
Thanks
John
Last edited: