Forum Discussion

NAl's avatar
NAl
Contributor
4 years ago
Solved

Limit results to 1 record on Salesforce Lookup Snap

We are using a Salesforce Lookup snap to return Account record Id’s based on a bunch of conditions. At the moment, if there are duplicate records in Salesforce, SnapLogic returns more than 1 id. We’d like to limit that to just 1, the first returned result.

Returning more than 1 result causes the creation of additional documents and problems further downstream.

  • Hi @NAl

    You can switch from Salesforce Lookup Snap to Salesforce Read Snap where you can specify the number of rows to be returned from Salesforce, in Limit Clause field:

    Also, all the conditions that you have in Lookup Snap you can put in the Where Clause field of the Salesforce Read Snap, so you will get identical results.

    If you don’t want to switch the Lookup Snap, then another solution can be to Group the returned records from Salesforce, in SnapLogic(based on the duplicate columns) and then to pick the first record from each group.

    Regards,
    Spiro Taleski

6 Replies

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    Hi @NAl

    You can switch from Salesforce Lookup Snap to Salesforce Read Snap where you can specify the number of rows to be returned from Salesforce, in Limit Clause field:

    Also, all the conditions that you have in Lookup Snap you can put in the Where Clause field of the Salesforce Read Snap, so you will get identical results.

    If you don’t want to switch the Lookup Snap, then another solution can be to Group the returned records from Salesforce, in SnapLogic(based on the duplicate columns) and then to pick the first record from each group.

    Regards,
    Spiro Taleski

  • NAl's avatar
    NAl
    Contributor

    Hi Spiro,
    That’s brilliant thank you. I had tried to tackle this by using the Group by N snap but it was definitely a longer workaround. I do have another question, the Where Clause in the Salesforce Read snap doesn’t seem to accept a multi query clause. I’ve tried using the following operators but the query fails

    and
    &&
    +

    If I split the clause up, the snap responds and works with each one but combined it doesn’t seem to return the necessary id’s.

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    @NAl

    I assume that the Salesforce Read Snap support all the SOQL operators. You can refer to the Salesforce SOQL documentation in order to check what operators are supported.

    Can you please share the conditions that you currently have in Salesforce Lookup Snap, that you want to replace in Read Snap?

    Regards,
    Spiro Taleski

  • NAl's avatar
    NAl
    Contributor

    1st condition: “Name = '” + $client + “'”
    2nd condition: "Custom_Field__c = FALSE "

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    Try

    "Name = '" + $client + "' AND Custom_Field__c = FALSE"
    

    Regards,
    Spiro Taleski

    • NAl's avatar
      NAl
      Contributor

      Blimey that worked. I had the quotation marks in the wrong place.
      Thanks ever so much