Query Data: Viewer Tips

Efficient Data Querying in Viewer Feature

Introduction to SOQL in Viewer

This article delves into the intricacies of querying data in the Viewer feature, offering valuable insights on accessing and managing information efficiently. Salesforce Object Query Language (SOQL) offers a framework for querying Salesforce data. Understanding how to navigate and leverage SOQL within the Viewer feature can significantly enhance the user experience and streamline data retrieval processes.

Filtering Data Effectively Using SOQL

Filtering data is a crucial aspect of querying, as it allows users to narrow down search results based on specific criteria. SOQL provides a range of filtering options, such as WHERE clauses and logical operators, to refine queries and extract relevant information.

Example: to get Opportunity Product with Product2.Family equal 'Support'

...FROM OpportunityLineItem WHERE Product2.Family = 'Support'

Sorting Data for Better Organization Using SOQL

 SOQL enables users to sort records based on one or more fields in ascending or descending order, facilitating better data organization and readability. By incorporating sorting techniques into their queries, users can gain a clearer overview of the data hierarchy and identify patterns or trends more efficiently, ultimately enhancing data analysis and interpretation.

Example: to get Opportunity Product order by Product Family add ORDER BY Product2.Family ASC

... FROM OpportunityLineItem ORDER BY Product2.Family ASC

Use picklist Label and not API value - in Viewer

The Viewer tool provides a range of options for querying data, including a built-in query builder with predefined functions. Users can further enhance their data retrieval process by utilizing custom SOQL queries. With the ability to incorporate the "toLabel" function within their SOQL statements, users can differentiate between fetching the Picklist Label instead of the API value. This feature offers users more control over the data they extract and manipulate, enabling them to refine their query results to meet specific criteria precisely. By leveraging custom SOQL queries with the "toLabel" function, users can personalize their data retrieval process to align with their unique requirements, opening up new avenues for tailored information access within the Viewer tool.

Example: to get myPicklist__c label value add tolabel around your field api name

... Id,tolabel(myPicklist__c) FROM ...

Using Your Own SOQL

While Viewer offers predefined query builder, users can also harness the power of custom SOQL queries to tailor their data retrieval process to specific requirements. By writing custom SOQL statements, users can exercise greater control over the data they extract and manipulate, allowing for more precise and targeted query results. This flexibility empowers users to craft personalized queries that align with their unique data querying needs, unlocking new possibilities for information retrieval within the Viewer feature.

SOQL Retrieving Records Through a Lookup Relationship

Lookup relationships play a vital role in data modeling within Salesforce, establishing connections between different objects and records. SOQL offers capabilities to retrieve records through lookup relationships, enabling users to access related data across multiple entities seamlessly. By leveraging SOQL to navigate lookup relationships, users can retrieve interconnected data sets and gain a comprehensive understanding of the relational structure within their Salesforce environment, fostering deeper insights and enriched data analysis.

In viewer once you add a lookup relationship field us the View Data button to viewe the data and to copy the require token for your word template.

Example: to get Opportunity Account Name , you need to add Account.Name to your query

SELECT ... ,Account.Name FROM Opportunity ...

Retrieving Records: Complex query / Sun query / Relationship query

Important Note: It is highly recommended to create a new Data Item rather than relying on subqueries or Relationship queries. This method is crucial to ensure data accuracy, improve performance, and avoid potential issues that may arise from using subqueries. 

Lookup relationships are essential for creating connections between various objects and records in Salesforce data modeling. When using SOQL, you can access related data across multiple entities by retrieving records through subqueries with the viewer. This functionality allows users to navigate lookup relationships effectively, fetching interconnected data sets and gaining insights into the relational structure of their Salesforce environment. By leveraging the power of SOQL for subqueries with the viewer, users can conduct comprehensive data analysis and enhance their understanding of data relationships in Salesforce.

To access the merge tokens required for incorporating your data into a Word template, you must use utilize the "View Data" button and then navigate to the JSON view.

Example: to get Opportunity Products Using A Opportunity query, you need to add sub query to your query 

SELECT Amount, Name, 
(SELECT Quantity, ListPrice,PricebookEntry.Name,PricebookEntry.product2.Family 
  FROM OpportunityLineItems)
FROM Opportunity

Was this article helpful?

Regular Expression in Viewer App
Using Conditions and Functions in Viewer
Feedback