通过 suds 更新 JIRA 中的自定义级联选择字段

发布于 2024-10-17 06:42:01 字数 3617 浏览 2 评论 0原文

使用 JIRA 版本 4.2。使用 Python 2.7 和 suds 0.4,如何更新问题的自定义级联选择字段(父级和子级)?

在“Python (SOAPPy) 客户端”下有一个 SOAPpy 示例 ”。 我使用 无法执行此类更新://studio.plugins.atlassian.com/browse/JCLIMD" rel="nofollow">Python JIRA CLI。

例子: 更新父字段 customfield_10 的级联选择自定义子字段时,可能需要更新字段 customfield_10_1。

更新

显示级联字段原始值的代码:

issue = client.service.getIssue(auth, "NAHLP-33515")
for f in fields:
    if f['customfieldId'] == 'customfield_10050' or f['customfieldId'] == 'customfield_10050_1':
        print f

这导致:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }

手动设置级联字段的子级后,上述代码导致:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }
(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = "1"
   values[] =
      "11560",
 }

以上值是我希望通过suds实现的值强>。

请注意key = "1" 字段。键值指定该对象是 customfield_10050 的子对象。
文档参考parentKey - 用于多维自定义字段,例如级联选择列表。其他情况下为 Null

让我们尝试发送一个关键字段值:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050_1", "key":"1", "values":["11560"]}
                           ])

这会导致错误,因为 updateIssue 接受 RemoteFieldValue[] 参数,而不是 RemoteCustomFieldValue[] 参数 (谢谢 Matt Doar):

suds.TypeNotFound: Type not found: 'key'

那么我们如何通过用于更新问题的 RemoteCustomFieldValue 参数?

更新2,mdoar的答案

通过suds运行以下代码:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050_1", "values":["11560"]}
                           ])`

值后:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }

不幸的是,这不会更新customfield_10050的子项。手动验证。

解决方案:

谢谢mdoar!要更新级联选择字段的父字段和子字段,请使用冒号(“:”)指定子字段。

工作示例:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050:1", "values":["11560"]}
                           ])

Using JIRA version 4.2. With Python 2.7 and suds 0.4, how can I update an issue's custom cascading select's field (both parent and child)?

There is a SOAPpy example available under "Python (SOAPPy) client".
I was unable to perform this type of update using the Python JIRA CLI.

Example:
When updating the cascading select custom child of parent field, customfield_10, one would want to update the field customfield_10_1.

Update

Code to display cascading field's original value:

issue = client.service.getIssue(auth, "NAHLP-33515")
for f in fields:
    if f['customfieldId'] == 'customfield_10050' or f['customfieldId'] == 'customfield_10050_1':
        print f

This results in:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }

After manually setting the cascading field's child, the above code results in:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }
(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = "1"
   values[] =
      "11560",
 }

The above values is what I hope to achieve via suds.

Note the key = "1" field. The key value designates that this object is the child of customfield_10050.
Documentation reference:
parentKey - Used for multi-dimensional custom fields such as Cascading select lists. Null in other cases

Let's try sending a key field value:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050_1", "key":"1", "values":["11560"]}
                           ])

This results in an error because the updateIssue accepts a RemoteFieldValue[] parameter, not a RemoteCustomFieldValue[] parameter (thanks Matt Doar):

suds.TypeNotFound: Type not found: 'key'

So how do we pass a RemoteCustomFieldValue parameter to update an issue?

Update 2, mdoar's answer

Ran following code via suds:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050_1", "values":["11560"]}
                           ])`

After value:

(RemoteCustomFieldValue){
   customfieldId = "customfield_10050"
   key = None
   values[] =
      "10981",
 }

Unfortunately, this does not update the child of customfield_10050. Verified manually.

Resolution:

Thank you mdoar! To update a parent and child of a cascading select field, use the colon (':') to designate the child filed.

Working example:

client.service.updateIssue(auth, "NAHLP-33515", [
                           {"id":"customfield_10050", "values":["10981"]},
                           {"id":"customfield_10050:1", "values":["11560"]}
                           ])

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文