0

日時を使用して sfdc をクエリしようとしています。日付を文字列として使用してから日時オブジェクトとして使用しようとしましたが、このように使用すると不正な形式のクエリが取得されます

dateTime = sys.argv[1] 

result = sf.query("select Case__r.CaseNumber from File_Attachment__c where ( LastModifiedDate >= dateTime) ")

私も試しました

from dateutil.parser import parse dtime = parse(dateTime)

result = sf.query("select Case__r.CaseNumber from File_Attachment__c where ( LastModifiedDate >= dtime) ")

result = sf.query("select Case__r.CaseNumber from File_Attachment__c where ( LastModifiedDate >= :dtime) ")

しかし、すべてsfdcから不正な形式のクエリエラーが発生します。誰でも助けることができますか?

4

2 に答える 2

0

次のコードは、beatbox と python 2.7 を使用して正常なクエリを実行します。別のバージョンの Python を使用しているか、日付形式が正しくないか、クエリ パラメーターが正しくありません (Case__r.CaseNumber または File_Attachment__c)。

import beatbox

"salesforceusername and password"
username = 'xxx'
password = "xxx"
token    = 'xxx'

"""conenct and authenticate"""
svc = beatbox.PythonClient()
svc.login(username, password+token)

"""execut SOQL query"""
res = svc.query("select ID from Case where LastModifiedDate >= 2005-05-18T14:01:00-04:00")

"""prints results in console"""
print(res)
于 2016-05-19T05:49:41.873 に答える
0

Datetime の SFDC リンク- https://help.salesforce.com/articleView?id=000325035&type=1&mode=1 Datetime の Python リンク- https://www.journaldev.com/23365/python-string-to-datetime-strptime #:~:text=Python%20strptime(),-Python%20strptime()&text=This%20function%20is%20exactly%20opposite,datetime%20object%20to%20a%20string.&text=Here%20the%20function%20returns% 20struct_time、%20%20ctime()%20関数で返される

from simple_salesforce import Salesforce
sf = Salesforce(
username='XXX', 
password='XXX', 
security_token='XXX')
result = sf.query("SELECT Id, Email FROM Contact WHERE LastName = 'Jones'")
print(result)

リンクをクリックすると、Python コードの画像とその結果が表示されます

于 2021-01-16T19:01:49.290 に答える