Hi Experts,
I am writing a dynamic query to fetch role id and role name from Success Factors. However I am getting the following error in the message processing tab -
Can you please help me understand the issue with my groory code?
I want to fetch all the roleid and rolename if both the fields are send empty else i want to fetch roleid and rolename based on roleid or role name.
<?xml version="1.0" encoding="utf-8"?> <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>ServerErrorException</code> <message lang="en-US">Server was unable to understand the URI of your OData API request, which contained the invalid character text sequence of: [[roleId], [ ], [eq]] . Please check the correctness of your query syntax, especially for unexpected whitespace or punctuation. For API syntax requirements consult https://help.sap.com/viewer/d599f15995d348a1b45ba5603e2aba9b/PRODUCTION/en-US</message> </error>
Please find the groovy code snippet below-
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def properties = message.getProperties();
String RoleId = properties.get("ROLEID");
String RoleName = properties.get("ROLENAME");
String query="";
if((RoleId==null || RoleId.length()==0) && (RoleName==null || RoleName.length()==0))
{
query="RBPRole?\$select=roleId,roleName";
}
if((RoleId==null || RoleId.length()==0) && (RoleName!=null || RoleName.length()>0))
{
query="RBPRole?\$select=roleId,roleName&\$filter=roleName eq"+RoleName;
}
if((RoleId!=null || RoleId.length()>0) && (RoleName==null || RoleName.length()==0))
{
query="RBPRole?\$select=roleId,roleName&\$filter=roleId eq"+RoleId;
}
message.setProperty("QUERY_DYNAMIC",query);
return message;
}