1

How do you read custom field values that are returned to a variable? In the example belpw, if I had a custom field in a project called "Custom Field" I understand I can search and return it by saying:

results = client.search(ObjCode.PROJECT,{'groupID':user.homeGroupID},fields=['DE:Custom Field'])

How would I the read the value of the custom field that has spaces in the name? similar to:

print(results.status)

How would you do something similar for a custom field like:

print('results.CustomField')
2
  • I've played with this for about an hour and couldn't get it. The python module for Workfront seems to be made to be pretty cumbersome and it has not been updated in years. It is built upon api version 4.0 and we are currently on version 9.0. Commented May 18, 2018 at 14:48
  • Brian, here is a Workfront API module I wrote. We use this internally here. It is setup for Python 3. The documentation isn't great, but the code is well commented if you want to see how it works. You can also check out some of the end to end tests for what is effectively code samples. A bit more info here in the repo as well github.com/craiglathrop218/workfrontapi_plus Commented May 22, 2018 at 22:00

1 Answer 1

1

If the call runs successfully, the value of results should now be a JSON object. That JSON object should have several default fields such as ID and possibly name, but it will also have a field named DE:Custom Field and the value. For example:

{'ID':'ABC123F2010314AFE1...', 'DE:Custom Field': 'This is the value of my custom field'}

So in python you would get the value using square bracket notation (assuming you have converted from JSON to a python object). In this case

print(results['DE:Custom Field'])

Sign up to request clarification or add additional context in comments.

3 Comments

Tried that method and got the error TypeError: 'Issue' object is not subscriptable
Ahh, you are using the default Workfront API module. I don't recall how to use that but I think you will need something like results.data['DE:Custom Field']. Here is an alternative API that I wrote a while back pypi.org/project/workfrontapi-plus. The problem is that the default API has this kinda odd CRUD wrapper around it.
Craig, thanks for the help. How would you do that in the workfrontapi-plus? what would be the syntax?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.