cancel
Showing results for 
Search instead for 
Did you mean: 

[UDF] if not exist input element, return value must be returned "nulltext".

JohnPark
Explorer
0 Kudos

Hi SDNers.

I need to make a UDF for special case.

I made under UDF but it has a problem.

When I delete a element in test, I expect to be returned the "nulltext" value.

Let me know how to coding.

- source code -

public String One2One(String in1, Container container) throws StreamTransformationException{

if (in1==null) {

return "nulltext";

} else {

return in1;

}

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If u remove fields from the test tab, the field will have only SUPPRESS value in the queue.

So u have to check for suppress inside your UDF.

Or use "mapWithDefault" node function before ur UDF and check for ""(empty value) inside ur UDF.

Thanks,

Sona

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

Are you using the below code in the UDF??

public String One2One(String in1, Container container) throws StreamTransformationException{

if (in1==null) {

return "nulltext";

} else {

return in1;

}

}

If so it wont work. UDF itself a function and not possible to use a function inside a fn,

Try the below code,

if (in1==null) {

return "nulltext";

} else {

return in1;

}

Also "When I delete a element in test," -- wat does it mean?

Regards

Ramg.

JohnPark
Explorer
0 Kudos

Thank you, Ramg.

"When I delete a element in test," means,

After creating Message Mapping in ESR, we can see the "Test" tab.

Entering some values in source and getting the result.

When I enter some values in source, I delete some elements using right button of mouse.

and I wrote source code like you.

public String One2One(String in1, Container container) throws StreamTransformationException{

//*----


// this is real code

if (in1==null) {

return "nulltext";

} else {

return in1;

}

//*----


}

Former Member
0 Kudos

Use Mapwithdefault node function before your UDF function in the mapping,

Regards

Ramg

former_member200962
Active Contributor
0 Kudos
When I enter some values in source, I delete some elements using right button of mouse

make use of the exists function in your UDF check if the node exists or not....if it does not exist then return nulltext.....as of now you are checking if there is any value in the field.

Regards,

Abhishek.