Salesforce Service Cloud - Table Account NULL values - sql-server

I'm trying to obtain data from Service Cloud Salesforce but when I select the table in SSMS, the data is all NULL, so probably I'm not specifying the right columns or table.
Salesforce Report Builder
Salesforce Source Editor (Visual Studio)
When I run the report in Salesforce I can see that the country and postal code data are filled in, but when I read the documentation, I don't find the main column "Country" neither "Mailing Zip/Postal Code".
For the Zip Code, in this example, since it's also filled in the data about Billing Postal Code, this one I could obtain in the extraction, but for the country I can't find a column named "country", only "BillingCountry" and "ShippingCountry", but these columns do not contain any information.
Documentation:
https://developer.salesforce.com/docs/atlas.en-us.234.0.object_reference.meta/object_reference/sforce_api_objects_account.htm
Can anyone help here? I need to add on the select in salesforce source editor (visual studio) the right column names to obtain the country and the zip code.
Thank you,

Your report mixes fields from Account and Contact joined together by Contact.AccountId = Account.Id. You could edit it and expand the left sidebar to see which field comes from which object.
Account has Billing and Shipping address (2 sets of fields with actual names becoming BillingCity, BillingStreet... And Contact has Mailing address and Other Address.
So that's 4 * 6 fields across 2 tables out of the box. Can be muddied up further if you have "Person Accounts" enabled (some contacts get paired up as 1:1 relation to account instead of 1:n, in something that behaves a bit like materialised view for MS SQL people?). Also admin could rename one of the fields (API Names of columns stay the same but you'd see different labels in report and UI), add custom address fields...
See how these queries work for you. Try them out in Salesforce Developer Console (in web UI), or VSCode first, not in that tool you have.
Pure contacts
SELECT Id, FirstName, LastName, MailingStreet, MailingCity, MailingPostalCode
FROM Contact
WHERE MailingPostalCode = '4465-613'
LIMIT 10
Pure accounts
SELECT Id, Name, BillingStreet, BillingCity, BillingPostalCode
FROM Contact
WHERE BillingPostalCode = '4465-613'
LIMIT 10
Now JOIN (for normal Salesforce, B2B, where Account is more like a company and Contact is more like employee)
SELECT Id, FirstName, LastName, MailingStreet, MailingCity, MailingPostalCode, Account.Name, Account.City
FROM Contact
WHERE MailingPostalCode = '4465-613' AND Account.BillingPostalCode = '4465-613'
LIMIT 10
And since your second screenshot looks like you do have person accounts (more like B2C model, with standalone "1 man companies" like freelancers, doctors working in multiple hospitals, students in education...) try this one too
SELECT Id, Name, BillingCity, BillingPostalCode, ShippingCity, ShippingPostalCode, PersonMailingCity, PersonMailingPostalCode, PersonOtherCity, PersonOtherPostalCode
FROM Account
WHERE IsPersonAccount = true
LIMIT 10

Related

Summing up values from one column into one row on a different table when joining

I've only had a (frustrating) couple days experience with SQL Server, and I need some help, since I cant find anything related to my question when searching.
For background info, I'm working in an accountancy, and right now I'm trying to create a table for balance statements to use in crystal reports. Each invoice has multiple items, but for the statement I need to sum them all up with the invoice reference being the information that links the group of data that needs to be summarised.
So, what I need is to pull information from one table (dbo.SalesInvItems), this information including the date (InvDate), the due date (InvDueDate), and the customer name (CustomerName). This information stays the same with the Invoice Reference (InvRef), and it's what I want to use to link the two tables.
For example, Invoice Reference: 1478 will always have the date 14/05/18, the due date: 14/06/18 and the customer name: Pen Sellers Ltd.
The same Invoice Reference is used by multiple rows, but the only thing that changes (that I need) is the Invoice Item Total (InvItemTotal).
For example, the one reference will always be addressed to Pen Sellers, but one item has the Total as £13 and another item using the same reference is £20.
The Invoice Item Total is what I need to sum up. I want to add all the Invoice Item Total's together that have the same Invoice Reference, while joining the tables.
Sales Invoices
So when I've inserted the references into the table (sorry they're not the same in both pictures, I was having problems making examples and I made a mistake), I want to grab the information from the Invoice table to fill it in, going from this...
Pre Solution
To this...
Desired Result
The desired location is a table called dbo.Statement.
1.Is this even possible to do?
2.How would I go about doing this?
3.Is there a method I could use that would make sure that every time I insert an Invoice Reference into the Statement table, it would automatically pull out the data needed from the Invoice Table?
If any additional information is needed, just say and I'll do my best to provide it, I have never asked a question on here before and I'm new to SQL Server and coding in general.
Im using SQL Server Management Tool 2017
Thank You
Select item.InvRef
, item.CustomerName
, item.InvDate
, item.InvDueDate
, Sum(item.InvItemTotal) InvAmt
, sum(IsNull(payments.Amount,0)) PayAmount
, Sum(item.InvItemTotal) InvAmt - sum(IsNull(payments.Amount,0)) as Balance
from SalesInvItems item
left join payments -- you didn't define this
on item.InvRef = payments.InvRef
group by item.InvRef
, item.CustomerName
, item.InvDate
, item.InvDueDate
Select item.InvRef
, item.CustomerName
, item.InvDate
, item.InvDueDate
, Sum(item.InvItemTotal) InvAmt
from SalesInvItems item
left join Statement
on item.InvRef = Statement.Reference
group by item.InvRef
, item.CustomerName
, item.InvDate
, item.InvDueDate

Join / Sort Domain Name Column to Company Name Column (Fuzzy) Sheets

I have a list of columns in a Google Sheet.
(ID, name, title, company name) and then I have a domain column though the data in that column doesn't line up with the other respective columns. For example for the first row the domain should be pgconsulting.net not nixon.com as shown below. And so forth.
ID, Name, title, company, domain
02, Eric Mensin, CEO, PG Consulting,
Nixon.com
03, Nick Doe, Director, Nixon,
pgconsulting.net
04, Erin Mathews, Manager, Streetz,
poolcues.io
Is there anyway to ensure that the correct domain appears next to it's respective Company name (and the thereby correctly match the rest of the columns).
Thanks and your help is much appreciated!
Here is the function I discovered to make it work.
IF value exists in one cell match value based on another cell next to it.
=IF(ISERROR(MATCH(G2,J:J, 0)), "No Match", VLOOKUP(G2,J:K,2,FALSE))
In the above example, the G column contains the correctly ordered company names and the function is taking the value in G2 (in this case a company name) and trying to find it in the J column.
If not found the cell will display the "No Match". However, if found it will take the value located next to the J column (in this case domains are located in column K).
If you have two columns of domains and you want to choose the best one based on filters (in this case if the column contains facebook, or linkedin)
=SWITCH(L2,"linkedin.com",H2,"",L2,"facebook.com",H2,"")
And then if you want to combine best domain chosen, you can use the following code:
=IF(LEN(M2),M2,L2)

Batching Invoices in SSRS - One Invoice per Customer

I have a written an invoice report that bundles up various charges to customers during a month. I have a filter set to a Parameter for a customer code that I am using for testing purposes. The final product, however, I would like to be able to specify a date and have a separate invoice (ideally it's own PDF) generated for each customer. Is this achievable in SSRS?
Notes: Invoice number is a generated field that is a combo of MM-YYYY-CustCode so we don't need a register or some sort of incrementing facility for the invoice number.
Emailing the resulting PDFs to one email address is acceptable so we don't need the system to pull a unique address for each customer.
The selection string from the SQL is as follows (not sure its needed but just in case)
CAST(VP_BSL_OWnerTrn.accountingdate AS DATE) = #accountingdate
AND (VP_BSL_OWnerTrn.code = 'Rental Com'
OR VP_BSL_OWnerTrn.code = 'Mgmt Fee'
OR VP_BSL_OWnerTrn.code = 'Gifts/Amen'
OR VP_BSL_OWnerTrn.code = 'Handling')
AND VP_BSL_OWnerTrn.Price_Local <> 0
AND VP_BSL_OWnerTrn.RoomNo = #RoomNo
Thanks in advance for any help/advice.

how to pre-fill some parts of an access form?

New here, so be gentle with me. - edited to simplify
I'm trying to set up something in Access where:
user selects driver name and date
query finds stops along the driver's route
form opens with route stops (location details) filled in and user can add additional information (item picked up, weight of item)
all information gets transferred to a "Pickups" table, which has data on what was picked up, the weight, where (route stop) and by whom (driver).
I have stores A through H, and three drivers, Bob, Tom, and Jill. Bob’s route is stores A,B,C,D. Tom’s route is stores A,C,G,H, and Jill’s route is stores D,E,F,G. (I can't give real names/locations - work is very strict about privacy issues!)
Behind these are “Driver” Table, with driver name, ID, and truck info; and “Store” Table, with store name (A-H), address, phone number, and contact person.
We’re collecting all of the information about items picked up at each store into a “Pickup” table, with Fields: Date, Driver, Store, WeightOfFurniture, WeightOfBooks, WeightOfClothes
The user starts with the driver’s name and date, clicks a button, and this opens a form with the following fields:
Driver, Date, Store, WeightOfFurniture, WeightOfBooks, WeightOfClothes
with driver and date filled in based on the initial entry, and “Store” having all listings for a given driver’s route. So I select Bob and a date (11-12) and get a form with:
Name Date Store WtFurn WtBooks WtClothes
Bob 11-12 A
Bob 11-12 B
Bob 11-12 C
Bob 11-12 D
I can get the above information from a query without any problem, but I can't figure out how to (partially) fill the form with the query results (there will be multiple query results for a given route, so DLookup is not useful).
I think recordsets might be a way to go, but not sure how to do this. I'm very new at VBA, but am learning (the hard way!).
Any suggestions?
Thanks!
Use an INSERT INTO action query to insert those records into your Pickup table.
I can get the above information from a query without any problem,
This query is the SELECT FROM part for the INSERT query.
Then open your Pickup form, filtered for Driver, Date and Store that you just inserted.

Salesforce - Email Template Usage

Is there a quick method of reporting the usage of individual email templates within Salesforce on a Visualforce page? The usage data is already calculated and posted on the individual email templates page. I just need a method to query that data and report the usage for each email template on a summary page.
thanks
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_emailtemplate.htm
TimesUsed: Number of times this template has been used.
SELECT Id, Name, Subject, IsActive, TemplateType, LastUsedDate, TimesUsed
FROM EmailTemplate
WHERE TimesUsed > 0
ORDER BY TimesUsed DESC
LIMIT 10
Try this out too
SELECT Folder.Name, SUM(TimesUsed)
FROM EmailTemplate
WHERE IsActive = true
GROUP BY ROLLUP(Folder.Name)
(there will be 2 rows with blank folder name. First one will correspond to "unfiled public templates", second one will be a grand total row created because the ROLLUP function was used)

Resources