cancel
Showing results for 
Search instead for 
Did you mean: 

CPI: Access current "Model Step" from groovy script

Florian_Kube
Participant
0 Kudos
800

Hi all,

I would like to access the current Model Step in Groovy. Is there a way I can access it?

Thanks in advance,

Regards Florian

MortenWittrock
Active Contributor
0 Kudos

Hi Florian

I don't think that's possible. Could you expand a bit on what you're trying to accomplish?

Regards,

Morten

Accepted Solutions (0)

Answers (3)

Answers (3)

filipe_rieger
Explorer
0 Kudos

Hi Florian,

you can at least read the ID from the message history to dynamically set the MPL name. A little bit ugly, but for me it works.

def messageHistories = message.getProperty(Exchange.MESSAGE_HISTORY).join(',')
def lastCallActivity = messageHistories.substring(messageHistories.lastIndexOf("CallActivity"), messageHistories.length());
def activity = lastCallActivity.substring(0, lastCallActivity.indexOf("]"));
Florian_Kube
Participant
0 Kudos

I created a influence request. Please feel free to submit.

Improvement Request Details - Customer Influence (sap.com)

945_500_4055
Explorer

Any update on this.

Florian_Kube
Participant
0 Kudos

Hi 7a519509aed84a2c9e6f627841825b5a,

i would like to use the name of the current step for the name of the attachment. During development we often use this to log the content of a response after request-reply. If we have further steps we cannot identify which attachment/log belongs to which call Then we first need to look into the log.

Otherwise we would need to edit the script for each log or add a content modifier to set the name via property.

def Message plain_text(Message message) {
    messageLogFactory.getMessageLog(message)?.addAttachmentAsString(message.getCurrentStepName(), message.getBody(String), 'text/plain')
    return message
}

Thanks for your help

Regards Florian

MortenWittrock
Active Contributor

It's an interesting question, Florian. I've had three ideas so far, but unfortunately none of them worked 😄 I haven't given up, though.