cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Translate the entire conversation x

Obtain expression robot name from called java class

dsodling
10-Marble

Obtain expression robot name from called java class

All,

 

I have a scenario where I am calling a custom java method from an expression robot in a workflow. I pass the self and primaryBusinessObject references as parameters to the call and what I need is to get the name of the expression robot. This is not a problem when the call is made from an assigned activity because then the self variable refers to the activity from which I can get the name. However, when self is send from an expression robot it refers to the process itself. 

 

Does anybody know how to get the name of the expression robot? I should mentions that in this particular scenario I do not want to pass it as a parameter to the method.

ACCEPTED SOLUTION

Accepted Solutions
RandyJones
20-Turquoise
(To:dsodling)


@dsodling wrote:

All,

 

Does anybody know how to get the name of the expression robot? I should mentions that in this particular scenario I do not want to pass it as a parameter to the method.


One way to do this is to add a Workflow String variable eg robotName then in the robot do this:

robotName = "Name of this robot";

new com.xyz.CustomClass(self, primaryBusinessObject);

 

This robotName variable can then be extracted in the custom class:

CustomClass(ObjectReference self, Object primaryBusinessObject) {
  WfProcess wfProcess = self.getObject();
  ProcessData processData = wfProcess.getContext();
  String robotName = null;
  Object wfVariable = processData.getValue("robotName");
  if ((wfVariable != null) && wfVariable instanceof String) {
    robotName= (String) wfVariable;
  }
  // you now have the robotName to do with as needed
}

 

View solution in original post

4 REPLIES 4
FK_11475004
6-Contributor
(To:dsodling)

Hi @dsodling ,

I havent had the time to go digging around how exactly it works but I have noticed that by using the "Externalize Expressions" action, the generated java class file created method names that correspond to the wf robots (including expressions).

What I can see is that the ids created match what is in the WF Template XML when exported, but those ids tend to change frequently; basically, on every export.

 

I assume then that if you can peak into this process there will be some hint as to how that is achieved. see also Externalizing Expressions for a Workflow Template

 

Sorry it's not a direct solution but maybe this is helpful,

/Felix

 

FYI:
Im getting method names like:

for expression robots

wfExprRobotTemplate_230529__ROBOT_EXPRESSION_

for wfactivities in the Start transition specifically in this case

wfAssignedActivityTemplate_230514_START

for conditionals:

wfConnectorTemplate_230552__ROUTER_EXPRESSION_

Thank for the hint!

As you say, it is not a complete solution but I will for sure look into it.

Thanks again!

RandyJones
20-Turquoise
(To:dsodling)


@dsodling wrote:

All,

 

Does anybody know how to get the name of the expression robot? I should mentions that in this particular scenario I do not want to pass it as a parameter to the method.


One way to do this is to add a Workflow String variable eg robotName then in the robot do this:

robotName = "Name of this robot";

new com.xyz.CustomClass(self, primaryBusinessObject);

 

This robotName variable can then be extracted in the custom class:

CustomClass(ObjectReference self, Object primaryBusinessObject) {
  WfProcess wfProcess = self.getObject();
  ProcessData processData = wfProcess.getContext();
  String robotName = null;
  Object wfVariable = processData.getValue("robotName");
  if ((wfVariable != null) && wfVariable instanceof String) {
    robotName= (String) wfVariable;
  }
  // you now have the robotName to do with as needed
}

 

I kind of feel a bit dumb now for not thinking about that 😊

Thanks!

Announcements
Top Tags