web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

How to remove last two characters in liquid code

(0) ShareShare
ReportReport
Posted on by 195

Hi,

KABrandfilter=1700070,1700071,1700072,1700073

brandfilter=1700070,1700071

{% capture bffilter %}
{% assign brand = {{KABrandfilters}} | split:"," %}
{% for item in brand %}
{% unless brandfilter contains item %}
new_brandmultiselectstring ne '{{item}}' or
{% endunless %}
{% endfor %}
{% endcapture %}

Output: new_brandmultiselectstring ne '1700072' or new_brandmultiselectstring ne '1700073' or

Want to remove the last two characters "or"

Required output : new_brandmultiselectstring ne '1700072' or new_brandmultiselectstring ne '1700073' 

Please help me with this.Thanks in advance!!

Regards,

Susritha

I have the same question (0)
  • PriyankaKambleMSCRM365 Profile Picture
    5 on at

    Hi,

    We can add or as prefix while looping through and at last we can remove first or keyword. Below solution is tried and tested and works absolutely fine.

    Mark this answer as helpful if it’s works for u! Thanks in advance

    {% capture brandfiltersearchoptions %}

        {% if brandfilter[0]!='' %}

             {% for brandvalue in brandfilter %}

                {% if AllowedBrands contains brandvalue %}

                 {% if forloop.index > 1 %} or {% endif %}

                 {% if brandvalue =='717690000' %} BrandUSAA eq true {% endif %}

                 {% if brandvalue =='717690001' %} BrandMrCooper eq true {% endif %}

                 {% if brandvalue =='717690002' %} BrandVUL eq true {% endif %}

                 {% if brandvalue =='717690003' %} BrandUWM eq true {% endif %}

                 {% if brandvalue =='717690004' %} BrandPAD eq true {% endif %}

                {% endif %}

             {% endfor %}

       {% else %}

            BrandMrCooper eq true

       {% endif %}  

    {% endcapture %}

    {% assign brandfiltersearchoptions =  brandfiltersearchoptions | remove_first: "or"  %}

  • Susritha Profile Picture
    195 on at

    If I remove "or" then how will I get new_brandmultiselectstring ne '1700072' or new_brandmultiselectstring ne '1700073' .Want to remove the last or

  • LuHao Profile Picture
    40,892 on at

    Hi Susritha,

    You could remove "or" from the liquid code.

    {% capture bffilter %}
    {% assign brand = {{KABrandfilters}} | split:"," %}
    {% for item in brand %}
    {% unless brandfilter contains item %}
    new_brandmultiselectstring ne '{{item}}' or
    {% endunless %}
    {% endfor %}
    {% endcapture %}

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 21 Super User 2025 Season 2

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 14

#3
LightningStrikes Profile Picture

LightningStrikes 9

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans