Compare a String Variable

Hi ,
In the flow services(Mapping service ) i would like to compare a String variable with an initialised variable using a transformer …I have checked the pub.String folder and i could not find a CompareTo Util in it …
IS there something like compareTo() function that we use in java …

Dhiraj Shetty

Dhirah Sheety,

Why do you need to do the comparison in a Map step? Are you looking for a lookup function to transform a value?


you can simply create a java service with two input params and one output as follow:

String out = “”;
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String field1 = IDataUtil.getString( pipelineCursor, “field1” );
String field2 = IDataUtil.getString( pipelineCursor, “field2” );

if (field1.equalsIgnoreCase(field2))
    out = "true";
    out = "false";

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “value”, out);



and calling it from every flow you want.

Hope this can help you


There is a sample service called string:compareString in package,get this useful package from

Just copy the service in your custom package/folder and invoke it in your flow,it should work.

Elese flow with VS shared custom Javaservice above.


1 Like

Hi Mark,
You are right i need a look uo function for Transformer inorder to compare an IS-Doc variable with a constant varible …
I do not want to use a Java Service for the same do i am trying to explore the functions in the Web-Methods package …The built-In pub.String utility has limited functionalities…

Thanks for taking your valuable time out …

Thanks and regards
Dhiraj Shetty

Thanks for the PSUtilies …I have tried it …But we canot use the Third Party tool in our project …

Thanks and regards
Dhiraj SHetty

Hi VS,
I have tried Java service for the same but i wanted to explore the Flow service for the same as Java service has to be used to the mininal as per architiecture …
Is there a tranformer which compared 2 Strings…

thanks and regards
DHiraj Shetty


Its not a thirdparty tool,it is developed by webMethods Professional services and these are not avail in WmPublic.This is gone thru by almost everyone.

Just copy the service into your package/folder and invoke it in your flow service and test end to end,you can customize the service at your own risk.

Also you can invoke java services as a transformer same you do for built-in service which accomplishes the same.


1 Like

The built-in service provided by webMethods are just java services (and occasionally Flow services). Creating a simple service to act as a transformer that compares two strings is a perfect example of when it is OK to use a java service instead of a Flow. That is, what you want to create is a small, discrete piece of functionality that does not already exist in the IS built-in services.

Your only Flow option is to use a BRANCH statement to evaluate your variable and multiple (redundant) MAP statements to perform the conditional mapping. As an architect, I would much prefer writing a java service to provide this utlity function over having redundante MAP steps. Both approaches will work, one is “brute force” and one is elegant.


1 Like


I was reading through this post and I was trying to understand what exactly you are trying to accomplish with this service, but I’m not sure if I was able to. Somewhere along the post, I saw that all you are trying to do is a look-up of some sort. Is that correct?

If so, then have you looked into the pub.string:lookupTable service?

  • Percio