Nested Compare Handlebar Expression

Comments

3 comments

  • Ghia Amigable

    Hi Anna,

    I slightly modified what you created since the idea is already there. You can try the ones below:

    {{#compare OpportunityLineItems.[*].Product_Code__c "==" "TC001"}}{{multiply TCV ".80"}}{{else}}{{TCV}}{{/compare}}

    {{#compare OpportunityLineItems.[*].Product_Code__c "==" "TC002"}}{{multiply TCV ".20"}}{{else}}{{TCV}}{{/compare}}

    Hope this works out for you!

    0
  • Anna Lucas

    That didn't quiet work because it was giving me multiple outputs. I ended up with this 

    {{#compare OpportunityLineItems.[*].Product_Code__c "==" "TC001"}}{{multiply TCV ".80"}}{{/compare}}

    {{#compare OpportunityLineItems.[*].Product_Code__c "==" "TC002"}}{{multiply TCV ".20"}}{{else}}{{TCV}}{{/compare}}

    but now I am getting an error that says I have more than 5 decimal places

    0
  • Robert Boone

    Hello Anna,

    If you're using these two compare handlebars in the same mapping, you can combine the compare statements as well as add a tofixed handlebar to control the number of decimal places.

    Here is a solution that may work for you.


    {{#compare OpportunityLineItems.[*].Product_Code__c "==" "TC001"}}{{toFixed (multiply TCV ".80") 2}}{{else compare OpportunityLineItems.[*].Product_Code__c "==" "TC002"}}{{toFixed (multiply TCV ".20") 2}}{{else}}{{TCV}}{{/compare}}

    Hope this helps.

    0

Please sign in to leave a comment.