I have a list that is structured like so:
[{'Id'}, {'IsDeleted'}, {'MasterRecordId'}, {'Name'}, {'Title'}, {'Company'}]
I want to turn it into a string that looks like this:
Id, IsDeleted, MasterRecordId, Name, Title, Company
I've gone through the top answer here:
Removing a list of characters in string
and a few others.
Here's the code I have so far:
sf = Salesforce(instance_url='insideigt--tony.sandbox.my.salesforce.com/',
username='igtdataimport@igt.com.tony',
password='TXRZ51rRe',
security_token='2IagJSrI5H3zxeVjgqy1xAN7d',
domain='test')
def getValidFeilds( sObject ):
fields = []
print(sObject)
schema = getattr( sf, sObject).describe()
for fieldDict in schema.get('fields', []):
fieldType = fieldDict.get('type')
if fieldType not in ['address', 'location'] and not fieldDict.get('compoundFieldName'):
fields.append({
fieldDict.get('name')
})
#np.array(fields).flatten()
chars_to_remove = ["'", "{" ,"}" ]
my_string= ','.join(map(str, fields))
my_string.translate(str.maketrans({"'":None}))
print(my_string)
return fields
sObject = 'Lead'
fields = getValidFeilds(sObject)