E9.2 Manipulate Outputs Errors

cazzafed

cazzafed

Active Member
Hello, how can I do to manipulate my output so that I can only receive what is highlighted in green?

1675168074638.png

EnterpriseOne 9.2.4.5
 

Attachments

  • 1675168003648.png
    1675168003648.png
    40.4 KB · Views: 10
The address to what is in green is "JAS Response"."fs_P4210_W4210G"."errors"[0]."DESC" if that's helpful :)

I haven't tried yet with handling a form request response as JSON though. I imagine it must be possible but would require more time to play than I personally have.

If you combine that address with the code in this post it might yield some results- again, you will probably need to massage the code a bit to get just what you want.
 
The address to what is in green is "JAS Response"."fs_P4210_W4210G"."errors"[0]."DESC" if that's helpful :)

I haven't tried yet with handling a form request response as JSON though. I imagine it must be possible but would require more time to play than I personally have.

If you combine that address with the code in this post it might yield some results- again, you will probably need to massage the code a bit to get just what you want.
Thank you I will give it a try.
 
The address to what is in green is "JAS Response"."fs_P4210_W4210G"."errors"[0]."DESC" if that's helpful :)

I haven't tried yet with handling a form request response as JSON though. I imagine it must be possible but would require more time to play than I personally have.

If you combine that address with the code in this post it might yield some results- again, you will probably need to massage the code a bit to get just what you want.
This is my JSON
but i can not read "JAS Response"."fs_P4210_W4210G"."errors"[0]."DESC"
Code:
{
  "message" : {
    "ServiceRequest: FREQ_SalesOrderEntry" : {
      "App Stack Form Exception" : {
        "Expecting Form" : "P4210_W4210A",
        "Resulting Form" : "P4210_W4210G_SADE201015"
      },
      "JAS Response" : {
        "fs_P4210_W4210G" : {
          "title" : "Sales Order Header",
          "data" : { },
          "errors" : [ {
            "CODE" : "007P",
            "TITLE" : "Error: Invalid Address Number",
            "ERRORCONTROL" : "0",
            "DESC" : "Cause  . . . . The Address number does not exist in the Address Book Master\u000a               file (F0101).\u000aResolution . . You may enter an Address number through the Address Book\u000a               Revisions program (P01012).  You may need to check the number\u000a               entered to see if the number entered is correct.",
            "MOBILE" : "The Address number does not exist in the Address Book Master\u000a               file (F0101)."
          }, {
            "CODE" : "1020",
            "TITLE" : "Error: Address Type Invalid",
            "ERRORCONTROL" : "0",
            "DESC" : "CAUSE . . . . You have entered an address number in the sold to field, but that\u000a              address number is coded as a ship to only address in billing\u000a              instructions. Or you have entered an address number in the ship to\u000a              field, but that address number is coded as a sold to only address\u000a              in the billing instructions.\u000aRESOLUTION. . If no address number was entered in the highlighted field, the\u000a              system will default an address based on the related address in\u000a              billing instructions.  This  default address may be coded as a\u000a              specific bill to or ship to and is not valid  for the address it\u000a              is defaulting to (see above).",
            "MOBILE" : "You have entered an address number in the sold to field, but that\u000a              address number is coded as a ship to only address in billing\u000a              instructions. Or you have entered an address number in the ship to\u000a              field, but that address number is coded as a sold to only address\u000a              in the billing instructions."
          } ],
          "warnings" : [ ]
        },
        "stackId" : 234,
        "stateId" : 2,
        "rid" : "d5e5efba0804d8c1",
        "currentApp" : "P4210_W4210G_SADE201015",
        "timeStamp" : "2023-02-13:14.59.47",
        "sysErrors" : [ ]
      }
    }
  },
  "exception" : "Exception",
  "timeStamp" : "2023-02-13T14:59:47.340-0300",
  "userDefinedErrorText" : ""
}


Code:
HashMap<String, Object> main(OrchestrationAttributes orchAttr, HashMap inputMap)
{
  HashMap<String, Object> returnMap = new HashMap<String, Object>();
  String input = (String)inputMap.get("DataSetIn");
 
    
    def jsonSlurper = new JsonSlurper();   
    def object = jsonSlurper.parseText(input);
    
    //def error = object; --> in this line i dont know how read on "JAS Response"."fs_P4210_W4210G"."errors"[0]."DESC" || I have searched how to access but I can't make it work for me
    
    returnMap.put("inErrorMessage", error)

  return returnMap;
}
 
I typo'd the address (missed the parent container), and additionally now that we have the full response JSON the address has grown!

Also you may want to be able to handle all of the errors that surface, in your new JSON you have 2. In the example below I'm collecting the 2 errors and reformatting them a bit to remove some of the extra stuff.

Try this (you might need to tweak a bit if the actual address of the orch output error array is different/deeper than the JSON you posted)

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);
  def errorMap = jsonIn
    .message
    ."ServiceRequest: FREQ_SalesOrderEntry"
    ."JAS Response"
    ."fs_P4210_W4210G"
    .errors
    .collect{["error code":it.CODE,"error title":it.TITLE,"error msg":it.DESC]};
  def jsonOut = new JsonBuilder(errorMap).toString();
  return jsonOut;
}

Results in
JSON:
[
  {
    "error code": "007P",
    "error title": "Error: Invalid Address Number",
    "error msg": "Cause  . . . . The Address number does not exist in the Address Book Master\n               file (F0101).\nResolution . . You may enter an Address number through the Address Book\n               Revisions program (P01012).  You may need to check the number\n               entered to see if the number entered is correct."
  },
  {
    "error code": "1020",
    "error title": "Error: Address Type Invalid",
    "error msg": "CAUSE . . . . You have entered an address number in the sold to field, but that\n              address number is coded as a ship to only address in billing\n              instructions. Or you have entered an address number in the ship to\n              field, but that address number is coded as a sold to only address\n              in the billing instructions.\nRESOLUTION. . If no address number was entered in the highlighted field, the\n              system will default an address based on the related address in\n              billing instructions.  This  default address may be coded as a\n              specific bill to or ship to and is not valid  for the address it\n              is defaulting to (see above)."
  }
]
 
I typo'd the address (missed the parent container), and additionally now that we have the full response JSON the address has grown!

Also you may want to be able to handle all of the errors that surface, in your new JSON you have 2. In the example below I'm collecting the 2 errors and reformatting them a bit to remove some of the extra stuff.

Try this (you might need to tweak a bit if the actual address of the orch output error array is different/deeper than the JSON you posted)

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);
  def errorMap = jsonIn
    .message
    ."ServiceRequest: FREQ_SalesOrderEntry"
    ."JAS Response"
    ."fs_P4210_W4210G"
    .errors
    .collect{["error code":it.CODE,"error title":it.TITLE,"error msg":it.DESC]};
  def jsonOut = new JsonBuilder(errorMap).toString();
  return jsonOut;
}

Results in
JSON:
[
  {
    "error code": "007P",
    "error title": "Error: Invalid Address Number",
    "error msg": "Cause  . . . . The Address number does not exist in the Address Book Master\n               file (F0101).\nResolution . . You may enter an Address number through the Address Book\n               Revisions program (P01012).  You may need to check the number\n               entered to see if the number entered is correct."
  },
  {
    "error code": "1020",
    "error title": "Error: Address Type Invalid",
    "error msg": "CAUSE . . . . You have entered an address number in the sold to field, but that\n              address number is coded as a ship to only address in billing\n              instructions. Or you have entered an address number in the ship to\n              field, but that address number is coded as a sold to only address\n              in the billing instructions.\nRESOLUTION. . If no address number was entered in the highlighted field, the\n              system will default an address based on the related address in\n              billing instructions.  This  default address may be coded as a\n              specific bill to or ship to and is not valid  for the address it\n              is defaulting to (see above)."
  }
]
Hi @DaveWagoner, thanks you so much... I modified some things and achieved my goal...
 
Hi @cazzafed could you please share your final code, I'm also facing the same issue. So it would be really helpful if you can share how you have done it.
 
Hi @cazzafed could you please share your final code, I'm also facing the same issue. So it would be really helpful if you can share how you have done it.
Actually, this manipulation was for an "Error Exception" of a Form Request, so, I execute an orchestration with a groovy function that has this code:
Code:
String input = (String)inputMap.get("DataSetIn");
 
    def jsonSlurper = new JsonSlurper();   
    def object = jsonSlurper.parseText(input);
    
    def errors = object.message
                ."ServiceRequest: FREQ_SOEntry"
                ."JAS Response"
                ."fs_P4210_W4210G"
                .errors
    def errorList = []
    errors.eachWithIndex { error, index ->
        errorList << "Error ${index+1}: ${error.CODE}, ${error.TITLE}, ${error.DESC}"
    }
    returnMap.put("inErrorMessage", errorList.join("\n"))

return the data as,

Error 1: 0130, Error: Payment Terms Code Invalid, CAUSE . . . . The payments term code has not been set up in the Payments Terms
 
Back
Top