web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • LuHao Profile Picture
    40,892 on at
    RE: How to remove last two characters in liquid code

    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 %}

  • Susritha Profile Picture
    195 on at
    RE: How to remove last two characters in liquid code

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

  • PriyankaKambleMSCRM365 Profile Picture
    5 on at
    RE: How to remove last two characters in liquid code

    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"  %}

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

Quick Links

Responsible AI policies

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

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 56

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 28 Super User 2025 Season 2

#3
mk1329 Profile Picture

mk1329 16

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans