0

I have a request to parse the description field and extract multiple values for certain entries such as: username = xxx fname = aaa lname = bbb. Once I have extracted these values they need to be conditionally rendered in the UI to make it easier for our users to know which case record they want to manage.

I am having issues with extracting the value after username = which should then be added to the case.classification. I tried the instr function but not getting the results am after.

End Result is like this: CAM - username. or CAM - xxx.

Case are being iterated through an aura component and rendered

<!-- CAM -->
<!-- add indicator (parse description for first and last name -->
  <aura:if isTrue="{!case.Classification__c == 'CAM' }">
    <aura:if isTrue="{!case.Sub_Classification__c == 'New' }">
      <!-- {! case.Description } -->
      {instr(! case.Description, 'username =')}

    <aura:set attribute="else">
      {! case.Classification__c + (not(empty(case.Sub_Classification__c)) ? ' (' + case.Sub_Classification__c + ')': '') }
    </aura:set>
</aura:if>

1 Answer 1

1

First, your expression is incorrect:

  {instr(! case.Description, 'username =')}

Would be:

  {!instr(case.Description, 'username =')}

Second, there is no such function as instr.

Third, setting values like this is best done in your controller or helper. Expressions are relatively limited, as they only have a handful of operators, limited to a few basic math operations, boolean comparisons, conditional branches, and a couple of string functions. Anything more complicated than that requires JavaScript.

1
  • Thank you sfdcfox. This is helpful in better understanding where do things and their limitations. I have made adjustments and pushed the evaluations into a separate reusable component and handle the parsing functions in javascript controller.
    – Daryn
    Commented Mar 8, 2022 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .