cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering task based on the properties using REST API

Tabu
Champ in-the-making
Champ in-the-making

Hi,
I am trying to filter the tasks based on the property filtration using the below code taken from TaskInstancesGet class. I was able to fetch all the properties whose values are Strings but couldn't fetch the values which are numbers or dates.

if (list_1 != null)
{
for (Object list_2 : list_1)
{
int propQNameEnd = list_2.toString().indexOf('/');
if (propQNameEnd < 1)
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Ignoring invalid property filter:" + list_2.toString());
}
break;
}
String propValue = list_2.toString().substring(propQNameEnd + 1);
if (propValue.isEmpty())
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Ignoring empty property value filter [" + propValue + "]");
}
break;
}
String propQNameStr = list_2.toString().substring(0, propQNameEnd);
QName propertyQName;
try
{
propertyQName = QName.createQName(propQNameStr, namespaceService);
}
catch (Exception ex)
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Ignoring invalid QName property filter [" + propQNameStr + "]");
}
break;
}
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Filtering with property [" + propertyQName.toPrefixString(namespaceService) + "=" + propValue + "]");
}
propertyFilter.put(propertyQName, propValue);
taskQuery.setProcessCustomProps(propertyFilter);
}
}

Please do check the code and let me know if there are any changes in the above so that i can filter the properties whose values are numbers or dates.

Any help would be appreciated..Thank you!

4 REPLIES 4

abhinavmishra14
World-Class Innovator
World-Class Innovator

@Wilbert1542 Posting spam is not allowed in the forum

~Abhinav
(ACSCE, AWS SAA, Azure Admin)

sanjaybandhaniya
Elite Collaborator
Elite Collaborator

You can add like this: 

propertyFilter.put(WorkflowModel.PROP_START_DATE, "dateValue");
propertyFilter.put(WorkflowModel.PROP_PRIORITY, "1");

Thanks for your reply!
But this can be used to filter out the date of a Workflow
I want to filter the tasks by their start date (Task Start Date)
So, if there's any solution please do provide it.

Hayes84
Champ in-the-making
Champ in-the-making

Glad you like it. We have been using this for several weeks now and it seems to be going nicely.