Skip to Main Content

Developer Community

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Embed FCCS rule's error pop-up inside Groovy script

SANDHI SENJun 5 2025

Hello Developers,

I have one groovy script in which FCCS business rule is called to execute. I am using RTPs for running the FCCS rules. I need to embed the FCCS rules related error message and the RTP validation check so that groovy script would validate the RTPs and also pop-up the FCCS rules errors when triggering the groovy script. So that the user need not to go to the FCCS jobs console to see the rules execution log after the groovy script execution finishes. I have the below code, which can be deployed successfully, but-

  1. It is providing false 'Invalid member' for Scenario Dimension (e.g.- I have 'Actual' as a Scenario member which I select during execution, but that was captured as 'Response for member "Actual" in dimension Scenario: xyz.epm.api.model.rest.HttpResponse@7dxc
    Response status: 400. Member "Actual" is not valid.
    Invalid Scenario RTP value: "Actual"'
  2. The groovy script is also not capturing the FCCS rule's error and providing the message 'rule executed with no error'. For example, if any period is lock in FCCS then during rule running, FCCS provides errors. But those errors are not coming during groovy script. It shows as 'completed with no error'

Below is the groovy script I have. Can anyone please help resolving the issue above. or how to proceed further?

/*RTPS: {Scenario} {Years} {Period} {Entity}*/
String sScenario = rtps.Scenario.toString()
String sYears = rtps.Years.toString()
String sPeriod = rtps.Period.toString()
String sEntity = rtps.Entity.toString()
long delay = 2500 // 2.5 seconds

// Helper: Validate RTP member against application dimension

boolean isValidMember(String dimension, String member) {
def response = operation.application
.getConnection("Consolidation Application")
.get("/rest/v3/applications/FccsApp/dimensions/${dimension}/members/${member}")
.asString()

println "Response for member ${member} in dimension ${dimension}: ${response}"

if (response.status == 200) {
def ctx = JsonPath.parse(response.body)
println "Response content: ${ctx}"
return true
} else {
println "Response status: ${response.status}. Member ${member} is not valid."
return false
}
}

// Validate all RTP members
if (!isValidMember("Scenario", sScenario)) {
println "Invalid Scenario RTP value: ${sScenario}"
return
}
if (!isValidMember("Year", sYears)) {
println "Invalid Year RTP value: ${sYears}"
return
}
if (!isValidMember("Period", sPeriod)) {
println "Invalid Period RTP value: ${sPeriod}"
return
}
if (!isValidMember("Entity", sEntity)) {
println "Invalid Entity RTP value: ${sEntity}"
return
}

// Function to poll job status
int getJobStatus(String jobId) {
HttpResponse<String> pingResponse = operation.application
.getConnection("Consolidation Application")
.get("/rest/v3/applications/FccsApp/jobs/" + jobId)
.asString()
return JsonPath.parse(pingResponse.body).read('$.status')
}

// Function to get job messages
void logJobMessages(String jobId) {
def jobDetailResp = operation.application
.getConnection("Consolidation Application")
.get("/rest/v3/applications/FccsApp/jobs/" + jobId)
.asString()

if (jobDetailResp.status == 200) {
def ctx = JsonPath.parse(jobDetailResp.body)
def messages = ctx.read('$.items[0].messages')

   if (messages) {  
       messages.each { msg ->  
       println "Job Message: ${msg}"  
       }  
   } else {  
       println "No messages returned from the job."  
   }  

} else {
println "Unable to fetch job messages. Status: ${jobDetailResp.status}"
}
}

// Execute Consolidation Rule
HttpResponse<String> jsonResponse = null
try {
jsonResponse = operation.application
.getConnection("Consolidation Application")
.post("/rest/v3/applications/FccsApp/jobs")
.header("Content-Type", "application/json")
/* .body(json([
"jobType": "Rules",
"jobName": "Consolidate",
"parameters": [
"Scenario": sScenario,
"Entity": sEntity,
"Year": sYears,
"Period": sPeriod
]
])).asString()*/

   .body(JsonOutput.toJson(\[  
       "jobType": "Rules",  
       "jobName": "Consolidate",  
       "parameters": \[  
           "Scenario": sScenario,  
           "Entity": sEntity,  
           "Year": sYears,  
           "Period": sPeriod  
       \]  
   \])).asString()

def ctx = JsonPath.parse(jsonResponse.body)
String jobId = ctx.read('$.jobId')
int statusCode = ctx.read('$.status')

while (statusCode == -1) {
sleep(delay)
statusCode = getJobStatus(jobId)
}

logJobMessages(jobId)

if (statusCode != 0) {
println "Consolidation job ended with status code: ${statusCode}"
}

} catch (Exception e) {
println "Exception during Consolidation Rule execution: ${e.getMessage()}"
}

Comments
Post Details
Added on Jun 5 2025
0 comments
71 views