Skip to main content

Notifications

Announcements

No record found.

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

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

  • Susritha Profile Picture
    Susritha 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

  • LuHao Profile Picture
    LuHao 40,876 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 %}

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans