simple_salesforce Feed Item@提到问题



在过去的几天里,我一直试图提到有人使用简单的salesforce和聊天,但没有成功。我尝试过不同的方法,但都没能给我带来满意的结果。

这很好,我可以为特定的parentid创建一个FeedItem,但@nature呈现为文本。

record = pd.DataFrame({'ParentId':['parent_salesforce_id']
,'Body':['{%salesforce_id} Test.']
,'Type':['TextPost']})
record = record.to_dict(orient="records")
results = sf.bulk.feeditem.insert(record)
results

到目前为止我尝试过的:

  • {salesforce_id}
  • {%salesforce_id}
  • @名字姓氏

在聊天[API文档][1]之后,我应该使用messageSegments来提到某人,但我的所有方法都失败了。

带有messageSegments:的示例代码

record = pd.DataFrame({'ParentId': 'parent_salesforce_id'
,'Body': [[{'messageSegments': {'text' : 'Test'}}]]
,'Type': 'TextPost'})
record = record.to_dict(orient="records")
results = sf.bulk.feeditem.insert(record)
results
Error message:
Out[14]: [{'success': False,
'created': False,
'id': None,
'errors': [{'statusCode': 'INVALID_FIELD',
'message': 'Unexpected JsonMappingException: Cannot deserialize instance of textarea from START_ARRAY value [ or request may be missing a required fieldn at [Source: java.util.zip.GZIPInputStream@74f8b7a1; line: 1, column: 35]',
'fields': []}]},
{'success': False,
'created': False,
'id': None,
'errors': [{'statusCode': 'INVALID_FIELD',
'message': "Unexpected JsonMappingException: No such column 'messageSegments' on sobject of type FeedItem",
'fields': []}]},
{'success': False,
'created': False,
'id': None,
'errors': [{'statusCode': 'INVALID_FIELD',
'message': "Json Deserialization failed on token 'text' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row",
'fields': ['text']}]}]

我一直在使用与前一篇文章[2]相同的方法。有人能帮我吗?提前谢谢。

[1]: https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/quickreference_post_feed_item.htm
[2]: https://stackoverflow.com/questions/55165029/mentioning-chatter-request-sfdc-using-simple-salesforce-in-python

我在Flow中解决了它,但它也应该在Apex代码中工作。试用括号:

'@['+salesforce_id+']'

最新更新