My problem lies with taking simple-salesforce queries out of the Salesforce and then Transforming them into a dataframe with Plotly Dashboard App.
I have tried to authenticate with Salesforce in Python (SUCCESS) I can request data and receive it with HTTP GET status (SUCCESS) I have an internal Dashboard App running Plotly Locally (SUCCESS) I have a general layout for the Dashboard App Locally (SUCCESS) Transforming Data query in Python into table/dataframe (FAILURE)
import os
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_table
import salesforce_reporting
from simple_salesforce import Salesforce
import requests
import pandas as pd
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go
# Salesforce User Session and Fields
# ==================================
from simple_salesforce import SalesforceAPI
sf = SalesforceAPI('<your username>', '<your salesforce password>', '<your salesforce token>')
Fields = ['isMosAlert__c',
'Milestone_violated__c',
'First_Reply__c',
'CaseNumber',
'Environment2__r.Name',
'Owner.Name',
'Severity_Level__c',
'Status',
'Subject',
'URL_for_support__c'
]
Items = str(Fields[1:10]).strip('[]')
print(Items).replace("'", "")
sf.query("SELECT %s from Case"% ','.join(Fields) )
#fig = go.Figure(data=[go.Table(header=dict(values=['A Scores', 'B Scores']),
# cells=dict(values=[[100, 90, 80, 90], [95, 85, 75, 95]]))
# ])
fig = go.Figure(data=[go.Table(header=dict(values=Fields),
cells=dict(values=[sf.query("SELECT %s from Case"% ','.join(Fields))]))
])
fig.show()
I actually do get a table, but all it shows is headers which I have defined as the fields data. Should the salesforce query be set to a variable? I want to get my table with Salesforce Data looking like the following picture that I took from Plotly Documentation
Actual information I get with the salesforce query returns like this while in python interactively.
(u'isMosAlert__c', True), (u'Milestone_violated__c', False), (u'First_Reply__c', True), (u'CaseNumber', u'1850637'), (u'Environment2__r', OrderedDict([(u'attributes', OrderedDict([(u'type', u'Environment__c'), (u'url', u'/services/data/v27.0/sobjects/Environment__c/a2X440000024ZkzEAE')])), (u'Name', u'MCP500 Production')])), (u'Owner', OrderedDict([(u'attributes', OrderedDict([(u'type', u'Name'), (u'url', u'/services/data/v27.0/sobjects/Group/00GE0000003YOIEMA4')])), (u'Name', u'L1 Support Group')])), (u'Severity_Level__c', None), (u'Status', u'Ignored'), (u'Subject', u'elasticsearch - critical'), (u'URL_for_Support__c', u'https://mirantis.my.salesforce.com/5004400000ykxS9')])])])