简体   繁体   English

simple_salesforce Feed 项目 @mention 问题

[英]simple_salesforce Feed Item @mention problem

I have been trying to mention someone using simple salesforce and chatter for past couple of days without success.在过去的几天里,我一直试图提及使用简单 salesforce 和喋喋不休的人,但没有成功。 I have tried different approaches and all of them fail to give me satisfying results.我尝试了不同的方法,但都没有给我满意的结果。

This works just fine and I am able to create a FeedItem for a specific parentid but @mention renders as a text.这工作得很好,我可以为特定的 parentid 创建一个 FeedItem,但 @mention 呈现为文本。

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

What I have tried so far:到目前为止我已经尝试过:

  • {salesforce_id} {salesforce_id}
  • {%salesforce_id} {%salesforce_id}
  • @FirstName LastName @FirstName 姓氏

Following chatter [API documentation][1] I should use messageSegments in order to mention someone, but all of my approaches fail.在 chatter [API 文档][1] 之后,我应该使用 messageSegments 来提及某人,但是我的所有方法都失败了。

Example code with 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 field\n 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']}]}]

I have been using the same approach as previous [stack post][2] about it.我一直在使用与之前的 [stack post][2] 相同的方法。 Is there anyone who might help me with this?有没有人可以帮我解决这个问题? Thank you in advance.先感谢您。

  [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

I solved it in a Flow but it should also work in Apex code.我在 Flow 中解决了它,但它也应该在 Apex 代码中工作。 Try with brackets:尝试使用括号:

'@['+salesforce_id+']'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM