AnsweredAssumed Answered

Error in groovy scripting

Question asked by amitash.pattnaik983074 on May 24, 2018
Latest reply on May 31, 2018 by amitash.pattnaik983074

Hi  Mates,

hope all you are doing well.

A little help is needed from you guys.I am very new to groovy.

I have a sample piece of code which is working fine  in java online interpreter.

The piece of code looks like this:-

import java.util.Properties;
import java.io.InputStream;
import java.text.MessageFormat;
import java.text.ParsePosition;
public class HelloBoomi{

public static void main(String []args){

Object formatargs[]= {"","Dell Boomi","Booming"};

System.out.println(formatargs.length);
String pattern ="Welcome to {1}.keep {2}";

String result =java.text.MessageFormat.format(pattern, formatargs);
System.out.println(result);
}
}

OutPut:-

Welcome to Dell Boomi.keep Booming

But when i tried the same piece of code in Custom Scripting in groovy it threw some error.Here the Requirement is little different from the
first one.The values stored in the Object formatargs[] and String pattern  are coming from 2 different DPPs. so  i make the code like this:-
import java.util.Properties;
import java.io.InputStream;
import com.boomi.execution.ExecutionUtil;
import java.text.MessageFormat;


propName = "DPP_Message";
propValue1 = ExecutionUtil.getDynamicProcessProperty(propName);
String pattern=propValue1;
parameterpropName="DPP_Parameter";
propValue2=ExecutionUtil.getDynamicProcessProperty(parameterpropName);
Object formatargs[]=propValue2;
String result =java.text.MessageFormat.format(pattern, formatargs);
propbody="DPP_MailBody";
ExecutionUtil.setDynamicProcessProperty(propbody, result, false);
for( int i = 0; i < dataContext.getDataCount(); i++ ) {
InputStream is = dataContext.getStream(i);
Properties props = dataContext.getProperties(i);

dataContext.storeStream(is, props);
}
it threw the error -" Caused by: No such property: formatargsfor class: Script56962 (in groovy script); Caused by: No such property:formatargsfor class: Script56962"
So, any idea guys,where the things are  going wrong?

Any help will be really appreciated.

Regards,
Amitash



Outcomes