General Technical Discussions for Service

Get Involved. Join the Conversation.

Topic

    Pramod Vasudeva Murthy
    Text Area field: Cannot Search on Text area field
    Topic posted February 25, 2019 by Pramod Vasudeva MurthyBlack Diamond: 60,000+ Points 
    194 Views, 9 Comments
    Title:
    Text Area field: Cannot Search on Text area field
    Summary:
    Cannot search in Text Area for ROQL and Report
    Content:

    Hi All,

    Is there a way where I can search a value in Text Area OR Query in ROQL?

    I am developing an automation and I am stuck here? Any help is appreciated.

    Thanks,

    Pramod V

    Version:
    18D

    Comment

     

    • Sebastiaan Draaisma

      Hi Pramod.

      I've done it through custom script. Let me look for an example report and get back to you.

    • Pramod Vasudeva Murthy

      Custom script? How?

      Text Area field is never exposed as a filter in the report nor in ROQL.

    • Sebastiaan Draaisma

      See attached report

      The trick is to use a variable that will be your search box which will then be used in a regular expression looking for a match through custom script. Rows with no match will be removed through unset.

      Initial

      global $filtersAndVariables;
      $filtersAndVariables = $params;

      Process

      global $filtersAndVariables;
      $var = $filtersAndVariables["param_args"]["param_item0"]["val"]; // Assign report variable value to $var
      $rows[0][0]->val = $filtersAndVariables["param_args"]["param_item0"]["val"]; // This line is not required, just for testing

      if(preg_match('/('.$var.')/', $rows[0][1]->val) == 0){ // Perform a regular expression match on the 2nd column
      unset($rows[0]); // If no match, delete the row
      }

      In the report editor you only need to change the custom field and then it should work.

    • Pramod Vasudeva Murthy

      Well, I am not quite sure if I had modified right. Let me tell you what I am trying to do here:

      • Have a custom object called Trainer(CO$Trainer) which has a Skillset(text area) field
      • Trying to set the same in second column of filter

      But doesn't seem to be working. Am I missing something here?

    • Sebastiaan Draaisma

      I haven't really worked with custom objects but I would think its the same.
      You will need to use the text area field in your 2nd column for it to work.

      When using aditional columns you may need to change the column id in the custom script.

    • Sebastiaan Draaisma

      I just did a quick test with a custom field (I don't have any CO active) with a match on search string
      It works as intended

    • Sebastiaan Draaisma

      Also, when using this in an exsisting report, code may need to be changed if you already use variables.
      As these will be available in an array you would probably need to change this line:

      $var = $filtersAndVariables["param_args"]["param_item0"]["val"]; // Assign report variable value to $var

      Use print_r($params,true) to catch the array value id when using multiple variables.

       

    • Pramod Vasudeva Murthy

      Thank you, Sebastian.

      I haven't had a chance to look at this lately, will try to experiment on this.

      ~VIP

    • Pramod Vasudeva Murthy

      Sorry, Sebastian.

      I had some trouble in setting this up. I had used global filters and need to have a contains filter in the text area. So my scenario is:

      I have a text area field, pass search text from filter and do a contains check in that field. I am sure of latter but not sure of inital setup.

      How do I pass values from global filters to process tab?

      ~VIP