I have a problem in filtering

Hi,

I have a problem with a document list that contains document lists in each index. Each document has a value structured like this:

<RandomRec>
    <RandomInfo>
        <Code></Code>
        <IntegrationType></IntegrationType>
        <StmtBankCode></StmtBankCode>
        <Website></Website>
        <Email></Email>
        <Phone></Phone>
    </RandomInfo>
    <RandomName>
        <EnShortName></EnShortName>
        <ArShortName></ArShortName>
        <EnName></EnName>
        <ArName></ArName>
    </RandomName>
    <RandomCategory>
        <EnShortName></EnShortName>
        <ArShortName></ArShortName>
        <EnName></EnName>
        <ArName></ArName>
    </RandomCategory>
    <RandomServices>
        <RandomService>
            <ServiceInfo>
                <Code></Code>
                <Type></Type>
                <EnShortDesc></EnShortDesc>
                <ArShortDesc></ArShortDesc>
                <EnDesc></EnDesc>
                <ArDesc></ArDesc>
                <PaymentType>prepaid</PaymentType>
            </ServiceInfo>
            <BillingInfo>
                <EnShortDesc></EnShortDesc>
                <ArShortDesc></ArShortDesc>
                <EnDesc></EnDesc>
                <ArDesc></ArDesc>
            </BillingInfo>
        </RandomService>
        <RandomService>
            <ServiceInfo>
                <Code></Code>
                <Type></Type>
                <EnShortDesc></EnShortDesc>
                <ArShortDesc></ArShortDesc>
                <EnDesc></EnDesc>
                <ArDesc></ArDesc>
                <PaymentType>Postpaid</PaymentType>
            </ServiceInfo>
            <BillingInfo>
                <EnShortDesc></EnShortDesc>
                <ArShortDesc></ArShortDesc>
                <EnDesc></EnDesc>
                <ArDesc></ArDesc>
            </BillingInfo>
        </RandomService>
    </RandomServices>
</RandomRec>

In this structure, the RandomRec is the parent document, and it has children such as RandomInfo, RandomName, RandomCategory, and RandomServices. Each document has a variable.

You want to divide the list into two categories based on the PaymentType defined in RandomRec -> RandomServices -> RandomService -> ServiceInfo -> PaymentType. If the user enters “postpaid,” you need to return the records that contain “postpaid”; otherwise, return the records that contain “prepaid”
please advise me whether the solution java code or flow service .
Thank you .

Hi Mohammad,

what about the following approach:

initialize three empty lists (postpaid, prepaid, generic) based on sub doctype RandomService
Loop over /RandomRec/RandomServices/RandomService
- Branch over /RandomRec/RandomServices/RandomService/ServiceInfo/PaymentType
-- Postpaid: add the RandomService Item to postpaid list
-- $default: add the RandomService Item to prepaid list
Branch on (userInput)/PaymentType
- Postpaid: map postpaid list to generic output list
- $default: map prepaid list to generic output list
return generic output list to the user

Regards,
Holger

1 Like

If you are publishing this document to a queue you can filter the messages in the trigger. This should be the most resource effective solution. Otherwise I would stick with Holgars solution. Check this document for filters configuration and try not to create multiple triggers for the same queue. You can use single trigger with multiple processes and conditions.

1 Like

Hi,

I am not sure if filtering is working with lists, when the list contains several entries with the same value for the field which is used for flitering.
The sample in the original post shows 2 entries, one for postpaid and one for prepaid, but what happens when there are several entries for postpaid and several entries for prepaid.

For readability reasons I would prefer to implement my suggestion in my previous post in Flow language, most of the steps can be done with built in services or by using predefined steps from Designer.
When postpaid step and $default step are put under a Sequence Step, you can add more processing in the Sequences.
Move the labels postpaid and $default to the Sequence Step then instead of the add step.

Regards,
Holger

They need to publish the elements of the list to a queue to get that filtered result. I don’t know anyway to filter the list from single message. Its still pretty easy and resource friendly though.

Hi Engin,

in this case we would need to know more about the facts what should happen with the data after filtering.

@Mohammad: can you provide some more details, how you want to continue processing the data after you have filtered the list, please?

Currently I do not see the neccessity to publish the lists to a queue, but this depends on the fact how the user wants to get the data presented.

Regards,
Holger

I am trying to do this but it’s not working .

I will try to use this thank you

ok thank you .

You should use flow service.

1 Like