Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-11960

Complex query expressions are not correctly parsed to SOQL for Salesforce

    Details

    • Target Version/s:
    • Support Ticket IDs:

      Description

      When defining a targetQuery against Salesforce, the queryFilter is parsed to SOQL for searching against Salesforce itself. However, for complex queries, the resulting SOQL does not work (although it is valid SQL (not SOQL)).

      As an example, the following targetQuery:

      (UserType eq \"ABC\" and !((ProfileID eq \"001\") or (ProfileID eq \"002\")))"
      

      Generates the following SOQL WHERE clause:

      WHERE 
          (
            NOT 
              (
                (
                  ProfileID = '001'
                ) 
                OR 
                (
                  ProfileID = '002'
                )
              ) 
            AND 
              (
                UserType = 'ABC'
              )
          )
      

      Which is rejected by Salesforce as Malformed:

      ERROR at Row:1:Column:3015\nexpecting a right parentheses, found 'AND'","errorCode":"MALFORMED_QUERY"}]
      

      The correct SOQL would be:

      WHERE ProfileID NOT IN ('001','002') AND (UserType = 'ABC')
      

        Attachments

          Activity

            People

            • Assignee:
              emanuel.brici Emanuel Brici
              Reporter:
              tom.wood Tom Wood
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: