0

I'm super new in development in general. I'm currently building a webapp that get data from Rally/CA Agile Central and put them in a neat table. My code:

response = rally.get('UserStory', fetch = True, query=query_criteria)
response_defect = rally.get('Defect', fetch = True, query=query_criteria)

story_list = []
if not response.errors:
    for story in response:
        #print (story.details())
        a_story={}
        #a_story['State'] = story.State.Name #if story.State else "Backlog"
        a_story['State']=story.BusOpsKanban if story.BusOpsKanban else "unassigned"
        #a_story['Status']=Story.Status if story.Status else "unassigned"
        a_story['id'] = story.FormattedID
        a_story['name'] = story.Name
        a_story['Opened']=(datetime.strptime(story.CreationDate, '%Y-%m-%dT%H:%M:%S.%fZ').strftime('%Y-%d-%b'))
        a_story['Requester']= story.Owner.Name if story.Owner else "unassigned"
        a_story['Blocked']= story.Blocked
        a_story['Service']=story.c_ServiceNowID

My issue is to get access to the value of the linkid of my customfield (c_ServiceNowID). When I run a Dict = I see that I have LinkID attributes but when I type

story.c_ServiceNowID.LinkID, I receive an error message telling me there is no such attributes.... How do I access this value using python ? Thank you

Fruchtzwerg
  • 10,999
  • 12
  • 40
  • 49

2 Answers2

0

According to the documentation at http://pyral.readthedocs.io/en/latest/overview.html#custom-fields, pyral allows you to reference the field without the c_ prefix

Most Artifact types in Rally can be augmented with custom fields. As of Rally WSAPI v2.0, the ElementName for a custom field is prefixed with ‘c_’. The pyral toolkit allows you to reference these fields without having to use the ‘c_’ prefix. For example, if your custom field has a DisplayName of ‘Burnt Offerings Index’ you can use the String of ‘BurntOfferingsIndex’ in a fetch clause or a query clause or refer to the field directly on an artifact as artifact.BurntOfferingsIndex.

Atmaram Shetye
  • 993
  • 7
  • 15
0

I think what you have should work, unless the ServiceNowID is empty. In that case there will not be a LinkID or DisplayString available on the ServiceNowID object.

If you update your code to check to make sure the Attribute is there, does it work?

if hasattr(story.c_ServiceNowID, 'LinkID'):
  a_story['Service']=story.c_ServiceNowID.DisplayString
  a_story['Link']=story.c_ServiceNowID.LinkID
Michael B
  • 341
  • 1
  • 5